Example usage for org.eclipse.jdt.internal.compiler.lookup InferenceContext18 InferenceContext18

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

Introduction

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

Prototype

public InferenceContext18(Scope scope, Expression[] arguments, InvocationSite site,
        InferenceContext18 outerContext) 

Source Link

Document

Construct an inference context for an invocation (method/constructor).

Usage

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

License:Open Source License

public InferenceContext18 freshInferenceContext(Scope scope) {
    int nArgs = this.arguments.length;
    final Expression[] expressions = new Expression[nArgs];
    long pos = 0L; // should never be used for error reporting, right?
    for (int i = 0; i < nArgs; i++) {
        Argument argument = this.arguments[i];
        expressions[i] = new SingleNameReference(argument.name, pos);
        expressions[i].resolvedType = argument.type.resolvedType;
    }/* ww w  .  jav a2s  . c o  m*/

    return new InferenceContext18(scope, expressions, this, 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/*  w w  w .  j ava2s  . c  o 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);
}