Example usage for org.eclipse.jdt.internal.compiler.ast ParameterizedQualifiedTypeReference dimensions

List of usage examples for org.eclipse.jdt.internal.compiler.ast ParameterizedQualifiedTypeReference dimensions

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.ast ParameterizedQualifiedTypeReference dimensions.

Prototype

@Override
    public int dimensions() 

Source Link

Usage

From source file:lombok.eclipse.handlers.EclipseHandlerUtil.java

License:Open Source License

/**
 * You can't share TypeReference objects or subtle errors start happening.
 * Unfortunately the TypeReference type hierarchy is complicated and there's no clone
 * method on TypeReference itself. This method can clone them.
 *///from   w ww . j  a  v a 2 s . co  m
public static TypeReference copyType(TypeReference ref, ASTNode source) {
    if (ref instanceof ParameterizedQualifiedTypeReference) {
        ParameterizedQualifiedTypeReference iRef = (ParameterizedQualifiedTypeReference) ref;
        TypeReference[][] args = null;
        if (iRef.typeArguments != null) {
            args = new TypeReference[iRef.typeArguments.length][];
            int idx = 0;
            for (TypeReference[] inRefArray : iRef.typeArguments) {
                if (inRefArray == null)
                    args[idx++] = null;
                else {
                    TypeReference[] outRefArray = new TypeReference[inRefArray.length];
                    int idx2 = 0;
                    for (TypeReference inRef : inRefArray) {
                        outRefArray[idx2++] = copyType(inRef, source);
                    }
                    args[idx++] = outRefArray;
                }
            }
        }

        TypeReference typeRef = new ParameterizedQualifiedTypeReference(iRef.tokens, args, iRef.dimensions(),
                copy(iRef.sourcePositions));
        if (source != null)
            setGeneratedBy(typeRef, source);
        return typeRef;
    }

    if (ref instanceof ArrayQualifiedTypeReference) {
        ArrayQualifiedTypeReference iRef = (ArrayQualifiedTypeReference) ref;
        TypeReference typeRef = new ArrayQualifiedTypeReference(iRef.tokens, iRef.dimensions(),
                copy(iRef.sourcePositions));
        if (source != null)
            setGeneratedBy(typeRef, source);
        return typeRef;
    }

    if (ref instanceof QualifiedTypeReference) {
        QualifiedTypeReference iRef = (QualifiedTypeReference) ref;
        TypeReference typeRef = new QualifiedTypeReference(iRef.tokens, copy(iRef.sourcePositions));
        if (source != null)
            setGeneratedBy(typeRef, source);
        return typeRef;
    }

    if (ref instanceof ParameterizedSingleTypeReference) {
        ParameterizedSingleTypeReference iRef = (ParameterizedSingleTypeReference) ref;
        TypeReference[] args = null;
        if (iRef.typeArguments != null) {
            args = new TypeReference[iRef.typeArguments.length];
            int idx = 0;
            for (TypeReference inRef : iRef.typeArguments) {
                if (inRef == null)
                    args[idx++] = null;
                else
                    args[idx++] = copyType(inRef, source);
            }
        }

        TypeReference typeRef = new ParameterizedSingleTypeReference(iRef.token, args, iRef.dimensions(),
                (long) iRef.sourceStart << 32 | iRef.sourceEnd);
        if (source != null)
            setGeneratedBy(typeRef, source);
        return typeRef;
    }

    if (ref instanceof ArrayTypeReference) {
        ArrayTypeReference iRef = (ArrayTypeReference) ref;
        TypeReference typeRef = new ArrayTypeReference(iRef.token, iRef.dimensions(),
                (long) iRef.sourceStart << 32 | iRef.sourceEnd);
        if (source != null)
            setGeneratedBy(typeRef, source);
        return typeRef;
    }

    if (ref instanceof Wildcard) {
        Wildcard original = (Wildcard) ref;

        Wildcard wildcard = new Wildcard(original.kind);
        wildcard.sourceStart = original.sourceStart;
        wildcard.sourceEnd = original.sourceEnd;
        if (original.bound != null)
            wildcard.bound = copyType(original.bound, source);
        if (source != null)
            setGeneratedBy(wildcard, source);
        return wildcard;
    }

    if (ref instanceof SingleTypeReference) {
        SingleTypeReference iRef = (SingleTypeReference) ref;
        TypeReference typeRef = new SingleTypeReference(iRef.token,
                (long) iRef.sourceStart << 32 | iRef.sourceEnd);
        if (source != null)
            setGeneratedBy(typeRef, source);
        return typeRef;
    }

    return ref;
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.util.IAlienScopeTypeReference.java

License:Open Source License

public AlienScopeParameterizedQualifiedTypeReference(ParameterizedQualifiedTypeReference proto,
        Scope alienScope) {/*from   w  w w.  j av a2  s  .  co m*/
    super(proto.tokens, proto.typeArguments, proto.dimensions(), proto.sourcePositions);
    this.alienScope = alienScope;
    this.isGenerated = true; // allow qualified reference to role
}