Example usage for org.eclipse.jdt.internal.compiler.ast TypeReference resolveType

List of usage examples for org.eclipse.jdt.internal.compiler.ast TypeReference resolveType

Introduction

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

Prototype

@Override
    public TypeBinding resolveType(ClassScope scope) 

Source Link

Usage

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

License:Open Source License

private ReferenceBinding resolveTemplates(final EclipseNode node, final Annotation annotation,
        final Class<?> templatesDef) {
    final EclipseType type = EclipseType.typeOf(node, annotation);
    final BlockScope blockScope = type.get().initializerScope;
    final char[][] typeNameTokens = fromQualifiedName(templatesDef.getName());
    final TypeReference typeRef = new QualifiedTypeReference(typeNameTokens,
            poss(annotation, typeNameTokens.length));
    return (ReferenceBinding) typeRef.resolveType(blockScope);
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.ast.MethodSpec.java

License:Open Source License

/**
 * Resolve and bind arguments, return type.
 * @param scope used for resolving. Newly bound arguments are entered here.
 * @param isBaseSide TODO// w  w  w . ja  v  a 2 s  . c om
 */
public void resolveTypes(CallinCalloutScope scope, boolean isBaseSide) {
    if (this.typeParameters != null) {
        for (int i = 0, length = this.typeParameters.length; i < length; i++) {
            if (isBaseSide)
                scope.problemReporter().illegalMappingRHSTypeParameter(this.typeParameters[i]);
            else
                this.typeParameters[i].resolve(scope);
        }
        if (!isBaseSide)
            scope.connectTypeVariables(this.typeParameters, true);
    }
    TypeBinding[] types = Binding.NO_PARAMETERS;
    if (this.arguments != null) {
        types = new TypeBinding[this.arguments.length];
        for (int i = 0; i < this.arguments.length; i++) {
            TypeReference type = this.arguments[i].type;
            if (isBaseSide)
                type.setBaseclassDecapsulation(DecapsulationState.ALLOWED);
            types[i] = type.resolveType(scope);
            if (types[i] != null) {
                type.resolvedType = types[i] = RoleTypeCreator.maybeWrapUnqualifiedRoleType(scope, types[i],
                        this.arguments[i]);
            } else {
                // ensure we have a type set!
                types[i] = type.resolvedType; // a ProblemBinding !?
                if (types[i] == null)
                    types[i] = new ProblemReferenceBinding(type.getTypeName(), null, ProblemReasons.NotFound);
            }

            // record in scope, needed for role types anchored to an argument
            // (all arguments must be bound in order!)
            this.arguments[i].bind(scope, types[i], false);
        }
    }
    if (this.hasSignature)
        this.argNeedsTranslation = new boolean[types.length];
    if (this.returnType != null) {
        if (isBaseSide)
            this.returnType.setBaseclassDecapsulation(DecapsulationState.ALLOWED);
        this.returnType.resolve(scope);
        if (this.returnType.resolvedType != null)
            this.returnType.resolvedType = RoleTypeCreator.maybeWrapUnqualifiedRoleType(scope,
                    this.returnType.resolvedType, this.returnType);
    }
    this.parameters = types;
}

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

License:Open Source License

public static void addException(AbstractMethodDeclaration methodDecl, TypeReference exceptionRef,
        boolean resolve) {
    if (methodDecl.thrownExceptions != null) {
        int len = methodDecl.thrownExceptions.length;
        System.arraycopy(methodDecl.thrownExceptions, 0,
                methodDecl.thrownExceptions = new TypeReference[len + 1], 1, len);
        methodDecl.thrownExceptions[0] = exceptionRef;
    } else {//from   w  w w  . ja v a 2s. c  om
        methodDecl.thrownExceptions = new TypeReference[] { exceptionRef };
    }
    if (resolve) {
        ReferenceBinding excType = (ReferenceBinding) exceptionRef.resolveType(methodDecl.scope);
        if (methodDecl.binding.thrownExceptions != null) {
            int len = methodDecl.binding.thrownExceptions.length;
            System.arraycopy(methodDecl.binding.thrownExceptions, 0,
                    methodDecl.binding.thrownExceptions = new ReferenceBinding[len + 1], 1, len);
            methodDecl.binding.thrownExceptions[0] = excType;
        } else {
            methodDecl.binding.thrownExceptions = new ReferenceBinding[] { excType };
        }
    }
}

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

License:Open Source License

/**
 * Augments the method signature with a special parameter
 * (adds an additional parameter at end of parameter list).
 * The type of the new parameter is the MarkerInterface-Type.
 * <code>public method(String str)</code>
 * will be augmented to//from  www . j  ava2  s .c om
 * <code>public method(String str, TSuper__OT__XYZ __OT__marker )</code>
 * where XYZ is the name of the direct superteam.
 * @param methodDeclaration the method of which Parameters will be augmented
 * @param origin superTeam used for part of the marker type's name
 */
public static void addMarkerArg(AbstractMethodDeclaration methodDeclaration, ReferenceBinding origin) {
    AstGenerator gen = new AstGenerator(methodDeclaration.sourceStart, methodDeclaration.sourceEnd);
    TypeReference marker = gen.singleTypeReference(TSuperHelper.getTSuperMarkName(origin));

    int argPos = 0;
    if (methodDeclaration.arguments == null) {
        methodDeclaration.arguments = new Argument[1];
    } else {
        int argumentlength = methodDeclaration.arguments.length;
        if (argumentlength == 0) {
            methodDeclaration.arguments = new Argument[1];
        } else {
            Argument[] arguments = new Argument[argumentlength + 1];
            System.arraycopy(methodDeclaration.arguments, 0, arguments, 0, argumentlength);
            methodDeclaration.arguments = arguments;
            argPos = argumentlength;
        }
    }
    methodDeclaration.arguments[argPos] = new Argument(MARKER_ARG_NAME, 0, marker, 0);
    methodDeclaration.isTSuper = true;
    if (methodDeclaration.binding != null) {
        TypeBinding[] oldParams = methodDeclaration.binding.parameters;
        TypeBinding[] newParams = new TypeBinding[oldParams.length + 1];
        System.arraycopy(oldParams, 0, newParams, 0, oldParams.length);
        newParams[oldParams.length] = marker.resolveType(methodDeclaration.scope);
        methodDeclaration.binding.parameters = newParams;
        methodDeclaration.binding.resetSignature();
    }
}