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

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

Introduction

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

Prototype

public MethodBinding getMethod(TypeBinding receiverType, char[] selector, TypeBinding[] argumentTypes,
            InvocationSite invocationSite) 

Source Link

Usage

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

License:Open Source License

private MethodBinding getAlternateMethod(Scope scope, ReferenceBinding superRole,
        TypeBinding[] extendedArgumentTypes) {
    MethodBinding alternateMethod = scope.getMethod(superRole, this.selector, extendedArgumentTypes, this);
    if (alternateMethod.problemId() == ProblemReasons.NotVisible) {
        return alternateMethod; // want to see this error as IProblem.IndirectTSuperInvisible, cf. ProblemReporter.invalidMethod
    }/*from  w w  w.  ja  v a 2  s  .  co m*/
    MethodBinding alternateSrc = alternateMethod.copyInheritanceSrc;
    // TODO(SH): binary verbatim copies (no marker arg) are not recognized as copies!
    if (alternateSrc != null && isRoleOfSuperTeam(alternateSrc.declaringClass, scope))
        return alternateMethod;
    return null;
}

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

License:Open Source License

/**
 * Find a method in type or one of its super types.
 * @param scope where the method shall be invoked from
 * @param type  where to search/*from  www  .  j a  v  a  2s.co m*/
 * @param selector name of the method
 * @param params params
 * @param decapsulationAllowed whether or not invisible methods should be found, too
 * @param site invocation site if available
 */
public static @Nullable MethodBinding findMethod(final Scope scope, ReferenceBinding type, char[] selector,
        TypeBinding[] params, boolean decapsulationAllowed, @Nullable InvocationSite site) {
    if (type == null || scope == null)
        return null;
    if (site == null) {
        final Expression[] fakeArguments = new Expression[params.length];
        for (int i = 0; i < params.length; i++) {
            fakeArguments[i] = new SingleNameReference(("fakeArg" + i).toCharArray(), 0L); //$NON-NLS-1$
            fakeArguments[i].resolvedType = params[i];
        }
        site = new InvocationSite() {
            @Override
            public int sourceStart() {
                return 0;
            }

            @Override
            public int sourceEnd() {
                return 0;
            }

            @Override
            public void setFieldIndex(int depth) {
                /* nop */ }

            @Override
            public void setDepth(int depth) {
                /* nop */ }

            @Override
            public void setActualReceiverType(ReferenceBinding receiverType) {
                /* nop */ }

            @Override
            public boolean receiverIsImplicitThis() {
                return false;
            }

            @Override
            public boolean isTypeAccess() {
                return false;
            }

            @Override
            public boolean isSuperAccess() {
                return false;
            }

            @Override
            public boolean isQualifiedSuper() {
                return false;
            }

            @Override
            public boolean checkingPotentialCompatibility() {
                return false;
            }

            @Override
            public void acceptPotentiallyCompatibleMethods(MethodBinding[] methods) {
                /* nop */ }

            @Override
            public TypeBinding invocationTargetType() {
                return scope.getJavaLangObject();
            }

            @Override
            public ExpressionContext getExpressionContext() {
                return ExpressionContext.ASSIGNMENT_CONTEXT;
            }

            @Override
            public TypeBinding[] genericTypeArguments() {
                return null;
            }

            @Override
            public InferenceContext18 freshInferenceContext(Scope someScope) {
                return new InferenceContext18(someScope, fakeArguments, this, null);
            }
        };
    }
    return scope.getMethod(type, selector, params, site);
}