Example usage for org.eclipse.jdt.internal.compiler.lookup Scope getBinding

List of usage examples for org.eclipse.jdt.internal.compiler.lookup Scope getBinding

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.lookup Scope getBinding.

Prototype

public Binding getBinding(char[] name, int mask, InvocationSite invocationSite, boolean needResolve) 

Source Link

Usage

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

License:Open Source License

private ITeamAnchor findVariable(Scope scope, char[] token, boolean isStaticScope, int start, int end) {
    if (scope instanceof ClassScope && ((ClassScope) scope).superTypeReference != null) {
        scope.problemReporter().extendingExternalizedRole(((ClassScope) scope).superTypeReference);
        return null;
    }/*w w w .  ja v a2s .  c  om*/
    VariableBinding anchorBinding = null;
    switch (scope.kind) {
    case Scope.METHOD_SCOPE:
        // check arguments for possible anchor:
        AbstractMethodDeclaration method = ((MethodScope) scope).referenceMethod();
        if (method != null) {
            Argument[] arguments = method.arguments;
            if (arguments != null)
                for (int i = 0; i < arguments.length; i++)
                    if (CharOperation.equals(arguments[i].name, token))
                        return RoleTypeCreator.resolveTypeAnchoredToArgument(method, i);
        }

        //$FALL-THROUGH$
    case Scope.BLOCK_SCOPE:
    case Scope.BINDING_SCOPE:
        anchorBinding = scope.findVariable(token);
        break;
    }
    if (anchorBinding == null) {
        Binding binding = scope.getBinding(token, Binding.VARIABLE, this, true);
        if (binding instanceof VariableBinding)
            anchorBinding = (VariableBinding) binding;
    }
    return checkAnchor(scope, this.anchor, token, start, end, anchorBinding);
}