Search in sources :

Example 1 with ReferenceContext

use of org.eclipse.jdt.internal.compiler.impl.ReferenceContext in project lombok by rzwitserloot.

the class PatchVal method clearIgnoreFurtherInvestigationField.

private static void clearIgnoreFurtherInvestigationField(ReferenceContext currentContext) {
    if (currentContext instanceof AbstractMethodDeclaration) {
        AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration) currentContext;
        methodDeclaration.ignoreFurtherInvestigation = false;
    } else if (currentContext instanceof LambdaExpression) {
        LambdaExpression lambdaExpression = (LambdaExpression) currentContext;
        setValue(getField(LambdaExpression.class, "ignoreFurtherInvestigation"), lambdaExpression, false);
        Scope parent = lambdaExpression.enclosingScope.parent;
        while (parent != null) {
            switch(parent.kind) {
                case Scope.CLASS_SCOPE:
                case Scope.METHOD_SCOPE:
                    ReferenceContext parentAST = parent.referenceContext();
                    if (parentAST != lambdaExpression) {
                        clearIgnoreFurtherInvestigationField(parentAST);
                        return;
                    }
                default:
                    parent = parent.parent;
                    break;
            }
        }
    } else if (currentContext instanceof TypeDeclaration) {
        TypeDeclaration typeDeclaration = (TypeDeclaration) currentContext;
        typeDeclaration.ignoreFurtherInvestigation = false;
    } else if (currentContext instanceof CompilationUnitDeclaration) {
        CompilationUnitDeclaration typeDeclaration = (CompilationUnitDeclaration) currentContext;
        typeDeclaration.ignoreFurtherInvestigation = false;
    } else {
        throw new UnsupportedOperationException("clearIgnoreFurtherInvestigationField for " + currentContext.getClass());
    }
}
Also used : CompilationUnitScope(org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope) BlockScope(org.eclipse.jdt.internal.compiler.lookup.BlockScope) Scope(org.eclipse.jdt.internal.compiler.lookup.Scope) CompilationUnitDeclaration(org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration) ReferenceContext(org.eclipse.jdt.internal.compiler.impl.ReferenceContext) AbstractMethodDeclaration(org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration) LambdaExpression(org.eclipse.jdt.internal.compiler.ast.LambdaExpression) TypeDeclaration(org.eclipse.jdt.internal.compiler.ast.TypeDeclaration)

Example 2 with ReferenceContext

use of org.eclipse.jdt.internal.compiler.impl.ReferenceContext in project bazel-jdt-java-toolchain by salesforce.

the class Parser method recoverStatements.

protected void recoverStatements() {
    class MethodVisitor extends ASTVisitor {

        public ASTVisitor typeVisitor;

        // used only for initializer
        TypeDeclaration enclosingType;

        TypeDeclaration[] types = new TypeDeclaration[0];

        int typePtr = -1;

        @Override
        public void endVisit(ConstructorDeclaration constructorDeclaration, ClassScope scope) {
            endVisitMethod(constructorDeclaration, scope);
        }

        @Override
        public void endVisit(Initializer initializer, MethodScope scope) {
            if (initializer.block == null)
                return;
            TypeDeclaration[] foundTypes = null;
            int length = 0;
            if (this.typePtr > -1) {
                length = this.typePtr + 1;
                foundTypes = new TypeDeclaration[length];
                System.arraycopy(this.types, 0, foundTypes, 0, length);
            }
            ReferenceContext oldContext = Parser.this.referenceContext;
            Parser.this.recoveryScanner.resetTo(initializer.bodyStart, initializer.bodyEnd);
            Scanner oldScanner = Parser.this.scanner;
            Parser.this.scanner = Parser.this.recoveryScanner;
            parseStatements(this.enclosingType, initializer.bodyStart, initializer.bodyEnd, foundTypes, Parser.this.compilationUnit);
            Parser.this.scanner = oldScanner;
            Parser.this.referenceContext = oldContext;
            for (int i = 0; i < length; i++) {
                foundTypes[i].traverse(this.typeVisitor, scope);
            }
        }

        @Override
        public void endVisit(MethodDeclaration methodDeclaration, ClassScope scope) {
            endVisitMethod(methodDeclaration, scope);
        }

        private void endVisitMethod(AbstractMethodDeclaration methodDeclaration, ClassScope scope) {
            TypeDeclaration[] foundTypes = null;
            int length = 0;
            if (this.typePtr > -1) {
                length = this.typePtr + 1;
                foundTypes = new TypeDeclaration[length];
                System.arraycopy(this.types, 0, foundTypes, 0, length);
            }
            ReferenceContext oldContext = Parser.this.referenceContext;
            Parser.this.recoveryScanner.resetTo(methodDeclaration.bodyStart, methodDeclaration.bodyEnd);
            Scanner oldScanner = Parser.this.scanner;
            Parser.this.scanner = Parser.this.recoveryScanner;
            parseStatements(methodDeclaration, methodDeclaration.bodyStart, methodDeclaration.bodyEnd, foundTypes, Parser.this.compilationUnit);
            Parser.this.scanner = oldScanner;
            Parser.this.referenceContext = oldContext;
            for (int i = 0; i < length; i++) {
                foundTypes[i].traverse(this.typeVisitor, scope);
            }
        }

        @Override
        public boolean visit(ConstructorDeclaration constructorDeclaration, ClassScope scope) {
            this.typePtr = -1;
            return true;
        }

        @Override
        public boolean visit(Initializer initializer, MethodScope scope) {
            this.typePtr = -1;
            if (initializer.block == null)
                return false;
            return true;
        }

        @Override
        public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
            this.typePtr = -1;
            return true;
        }

        private boolean visit(TypeDeclaration typeDeclaration) {
            if (this.types.length <= ++this.typePtr) {
                int length = this.typePtr;
                System.arraycopy(this.types, 0, this.types = new TypeDeclaration[length * 2 + 1], 0, length);
            }
            this.types[this.typePtr] = typeDeclaration;
            return false;
        }

        @Override
        public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) {
            return this.visit(typeDeclaration);
        }

        @Override
        public boolean visit(TypeDeclaration typeDeclaration, ClassScope scope) {
            return this.visit(typeDeclaration);
        }
    }
    class TypeVisitor extends ASTVisitor {

        public MethodVisitor methodVisitor;

        TypeDeclaration[] types = new TypeDeclaration[0];

        int typePtr = -1;

        @Override
        public void endVisit(TypeDeclaration typeDeclaration, BlockScope scope) {
            endVisitType();
        }

        @Override
        public void endVisit(TypeDeclaration typeDeclaration, ClassScope scope) {
            endVisitType();
        }

        private void endVisitType() {
            this.typePtr--;
        }

        @Override
        public boolean visit(ConstructorDeclaration constructorDeclaration, ClassScope scope) {
            if (constructorDeclaration.isDefaultConstructor())
                return false;
            constructorDeclaration.traverse(this.methodVisitor, scope);
            return false;
        }

        @Override
        public boolean visit(Initializer initializer, MethodScope scope) {
            if (initializer.block == null)
                return false;
            this.methodVisitor.enclosingType = this.types[this.typePtr];
            initializer.traverse(this.methodVisitor, scope);
            return false;
        }

        @Override
        public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
            methodDeclaration.traverse(this.methodVisitor, scope);
            return false;
        }

        private boolean visit(TypeDeclaration typeDeclaration) {
            if (this.types.length <= ++this.typePtr) {
                int length = this.typePtr;
                System.arraycopy(this.types, 0, this.types = new TypeDeclaration[length * 2 + 1], 0, length);
            }
            this.types[this.typePtr] = typeDeclaration;
            return true;
        }

        @Override
        public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) {
            return this.visit(typeDeclaration);
        }

        @Override
        public boolean visit(TypeDeclaration typeDeclaration, ClassScope scope) {
            return this.visit(typeDeclaration);
        }
    }
    MethodVisitor methodVisitor = new MethodVisitor();
    TypeVisitor typeVisitor = new TypeVisitor();
    methodVisitor.typeVisitor = typeVisitor;
    typeVisitor.methodVisitor = methodVisitor;
    if (this.referenceContext instanceof AbstractMethodDeclaration) {
        ((AbstractMethodDeclaration) this.referenceContext).traverse(methodVisitor, (ClassScope) null);
    } else if (this.referenceContext instanceof TypeDeclaration) {
        TypeDeclaration typeContext = (TypeDeclaration) this.referenceContext;
        int length = typeContext.fields.length;
        for (int i = 0; i < length; i++) {
            final FieldDeclaration fieldDeclaration = typeContext.fields[i];
            switch(fieldDeclaration.getKind()) {
                case AbstractVariableDeclaration.INITIALIZER:
                    Initializer initializer = (Initializer) fieldDeclaration;
                    if (initializer.block == null)
                        break;
                    methodVisitor.enclosingType = typeContext;
                    initializer.traverse(methodVisitor, (MethodScope) null);
                    break;
            }
        }
    }
}
Also used : MethodScope(org.eclipse.jdt.internal.compiler.lookup.MethodScope) ASTVisitor(org.eclipse.jdt.internal.compiler.ASTVisitor) ClassScope(org.eclipse.jdt.internal.compiler.lookup.ClassScope) BlockScope(org.eclipse.jdt.internal.compiler.lookup.BlockScope) ReferenceContext(org.eclipse.jdt.internal.compiler.impl.ReferenceContext)

Example 3 with ReferenceContext

use of org.eclipse.jdt.internal.compiler.impl.ReferenceContext in project bazel-jdt-java-toolchain by salesforce.

the class LambdaExpression method tagAsHavingErrors.

@Override
public void tagAsHavingErrors() {
    this.ignoreFurtherInvestigation = true;
    Scope parent = this.enclosingScope.parent;
    while (parent != null) {
        switch(parent.kind) {
            case Scope.CLASS_SCOPE:
            case Scope.METHOD_SCOPE:
                ReferenceContext parentAST = parent.referenceContext();
                if (parentAST != this) {
                    parentAST.tagAsHavingErrors();
                    return;
                }
            // $FALL-THROUGH$
            default:
                parent = parent.parent;
                break;
        }
    }
}
Also used : MethodScope(org.eclipse.jdt.internal.compiler.lookup.MethodScope) BlockScope(org.eclipse.jdt.internal.compiler.lookup.BlockScope) ClassScope(org.eclipse.jdt.internal.compiler.lookup.ClassScope) Scope(org.eclipse.jdt.internal.compiler.lookup.Scope) ReferenceContext(org.eclipse.jdt.internal.compiler.impl.ReferenceContext)

Example 4 with ReferenceContext

use of org.eclipse.jdt.internal.compiler.impl.ReferenceContext in project bazel-jdt-java-toolchain by salesforce.

the class MessageSend method resolveType.

@Override
public TypeBinding resolveType(BlockScope scope) {
    // Base type promotion
    if (this.constant != Constant.NotAConstant) {
        this.constant = Constant.NotAConstant;
        long sourceLevel = scope.compilerOptions().sourceLevel;
        boolean receiverCast = false;
        if (this.receiver instanceof CastExpression) {
            // will check later on
            this.receiver.bits |= ASTNode.DisableUnnecessaryCastCheck;
            receiverCast = true;
        }
        this.actualReceiverType = this.receiver.resolveType(scope);
        if (this.actualReceiverType instanceof InferenceVariable) {
            // not yet ready for resolving
            return null;
        }
        this.receiverIsType = this.receiver.isType();
        if (receiverCast && this.actualReceiverType != null) {
            // due to change of declaring class with receiver type, only identity cast should be notified
            TypeBinding resolvedType2 = ((CastExpression) this.receiver).expression.resolvedType;
            if (TypeBinding.equalsEquals(resolvedType2, this.actualReceiverType)) {
                if (!scope.environment().usesNullTypeAnnotations() || !NullAnnotationMatching.analyse(this.actualReceiverType, resolvedType2, -1).isAnyMismatch()) {
                    scope.problemReporter().unnecessaryCast((CastExpression) this.receiver);
                }
            }
        }
        // resolve type arguments (for generic constructor call)
        if (this.typeArguments != null) {
            int length = this.typeArguments.length;
            // typeChecks all arguments
            this.argumentsHaveErrors = sourceLevel < ClassFileConstants.JDK1_5;
            this.genericTypeArguments = new TypeBinding[length];
            for (int i = 0; i < length; i++) {
                TypeReference typeReference = this.typeArguments[i];
                if ((this.genericTypeArguments[i] = typeReference.resolveType(scope, true, /* check bounds*/
                Binding.DefaultLocationTypeArgument)) == null) {
                    this.argumentsHaveErrors = true;
                }
                if (this.argumentsHaveErrors && typeReference instanceof Wildcard) {
                    scope.problemReporter().illegalUsageOfWildcard(typeReference);
                }
            }
            if (this.argumentsHaveErrors) {
                if (this.arguments != null) {
                    // still attempt to resolve arguments
                    for (int i = 0, max = this.arguments.length; i < max; i++) {
                        this.arguments[i].resolveType(scope);
                    }
                }
                return null;
            }
        }
        // will check for null after args are resolved
        if (this.arguments != null) {
            // typeChecks all arguments
            this.argumentsHaveErrors = false;
            int length = this.arguments.length;
            this.argumentTypes = new TypeBinding[length];
            for (int i = 0; i < length; i++) {
                Expression argument = this.arguments[i];
                if (this.arguments[i].resolvedType != null)
                    // $NON-NLS-1$
                    scope.problemReporter().genericInferenceError("Argument was unexpectedly found resolved", this);
                if (argument instanceof CastExpression) {
                    // will check later on
                    argument.bits |= ASTNode.DisableUnnecessaryCastCheck;
                    this.argsContainCast = true;
                }
                argument.setExpressionContext(INVOCATION_CONTEXT);
                if ((this.argumentTypes[i] = argument.resolveType(scope)) == null) {
                    this.argumentsHaveErrors = true;
                }
            }
            if (this.argumentsHaveErrors) {
                if (this.actualReceiverType instanceof ReferenceBinding) {
                    // record a best guess, for clients who need hint about possible method match
                    TypeBinding[] pseudoArgs = new TypeBinding[length];
                    for (int i = length; --i >= 0; ) // replace args with errors with null type
                    pseudoArgs[i] = this.argumentTypes[i] == null ? TypeBinding.NULL : this.argumentTypes[i];
                    this.binding = this.receiver.isImplicitThis() ? scope.getImplicitMethod(this.selector, pseudoArgs, this) : scope.findMethod((ReferenceBinding) this.actualReceiverType, this.selector, pseudoArgs, this, false);
                    if (this.binding != null && !this.binding.isValidBinding()) {
                        MethodBinding closestMatch = ((ProblemMethodBinding) this.binding).closestMatch;
                        // record the closest match, for clients who may still need hint about possible method match
                        if (closestMatch != null) {
                            if (closestMatch.original().typeVariables != Binding.NO_TYPE_VARIABLES) {
                                // generic method
                                // shouldn't return generic method outside its context, rather convert it to raw method (175409)
                                closestMatch = scope.environment().createParameterizedGenericMethod(closestMatch.original(), (RawTypeBinding) null);
                            }
                            this.binding = closestMatch;
                            MethodBinding closestMatchOriginal = closestMatch.original();
                            if (closestMatchOriginal.isOrEnclosedByPrivateType() && !scope.isDefinedInMethod(closestMatchOriginal)) {
                                // ignore cases where method is used from within inside itself (e.g. direct recursions)
                                closestMatchOriginal.modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
                            }
                        }
                    }
                }
                return null;
            }
        }
        if (this.actualReceiverType == null) {
            return null;
        }
        // base type cannot receive any message
        if (this.actualReceiverType.isBaseType()) {
            scope.problemReporter().errorNoMethodFor(this, this.actualReceiverType, this.argumentTypes);
            return null;
        }
    }
    TypeBinding methodType = findMethodBinding(scope);
    if (methodType != null && methodType.isPolyType()) {
        this.resolvedType = this.binding.returnType.capture(scope, this.sourceStart, this.sourceEnd);
        return methodType;
    }
    if (!this.binding.isValidBinding()) {
        if (this.binding.declaringClass == null) {
            if (this.actualReceiverType instanceof ReferenceBinding) {
                this.binding.declaringClass = (ReferenceBinding) this.actualReceiverType;
            } else {
                scope.problemReporter().errorNoMethodFor(this, this.actualReceiverType, this.argumentTypes);
                return null;
            }
        }
        // https://bugs.eclipse.org/bugs/show_bug.cgi?id=245007 avoid secondary errors in case of
        // missing super type for anonymous classes ...
        ReferenceBinding declaringClass = this.binding.declaringClass;
        boolean avoidSecondary = declaringClass != null && declaringClass.isAnonymousType() && declaringClass.superclass() instanceof MissingTypeBinding;
        if (!avoidSecondary)
            scope.problemReporter().invalidMethod(this, this.binding, scope);
        MethodBinding closestMatch = ((ProblemMethodBinding) this.binding).closestMatch;
        switch(this.binding.problemId()) {
            case ProblemReasons.Ambiguous:
                // no resilience on ambiguous
                break;
            case ProblemReasons.InferredApplicableMethodInapplicable:
            case ProblemReasons.InvocationTypeInferenceFailure:
                // Grabbing the closest match improves error reporting in nested invocation contexts
                if (this.expressionContext != INVOCATION_CONTEXT)
                    break;
            // $FALL-THROUGH$
            case ProblemReasons.NotVisible:
            case ProblemReasons.NonStaticReferenceInConstructorInvocation:
            case ProblemReasons.NonStaticReferenceInStaticContext:
            case ProblemReasons.ReceiverTypeNotVisible:
            case ProblemReasons.ParameterBoundMismatch:
                // only steal returnType in cases listed above
                if (closestMatch != null)
                    this.resolvedType = closestMatch.returnType;
                break;
            case ProblemReasons.ContradictoryNullAnnotations:
                if (closestMatch != null && closestMatch.returnType != null)
                    this.resolvedType = closestMatch.returnType.withoutToplevelNullAnnotation();
                break;
        }
        // record the closest match, for clients who may still need hint about possible method match
        if (closestMatch != null) {
            this.binding = closestMatch;
            MethodBinding closestMatchOriginal = closestMatch.original();
            if (closestMatchOriginal.isOrEnclosedByPrivateType() && !scope.isDefinedInMethod(closestMatchOriginal)) {
                // ignore cases where method is used from within inside itself (e.g. direct recursions)
                closestMatchOriginal.modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
            }
        }
        return (this.resolvedType != null && (this.resolvedType.tagBits & TagBits.HasMissingType) == 0) ? this.resolvedType : null;
    }
    final CompilerOptions compilerOptions = scope.compilerOptions();
    if (compilerOptions.complianceLevel <= ClassFileConstants.JDK1_6 && this.binding.isPolymorphic()) {
        scope.problemReporter().polymorphicMethodNotBelow17(this);
        return null;
    }
    if (compilerOptions.isAnnotationBasedNullAnalysisEnabled) {
        ImplicitNullAnnotationVerifier.ensureNullnessIsKnown(this.binding, scope);
        if (compilerOptions.sourceLevel >= ClassFileConstants.JDK1_8) {
            if (this.binding instanceof ParameterizedGenericMethodBinding && this.typeArguments != null) {
                TypeVariableBinding[] typeVariables = this.binding.original().typeVariables();
                for (int i = 0; i < this.typeArguments.length; i++) this.typeArguments[i].checkNullConstraints(scope, (ParameterizedGenericMethodBinding) this.binding, typeVariables, i);
            }
        }
    }
    if (this.binding.isPolymorphic()) {
        boolean resultDetermined = compilerOptions.sourceLevel >= ClassFileConstants.JDK9 && (this.binding.returnType == TypeBinding.VOID || this.binding.returnType.id != TypeIds.T_JavaLangObject);
        if (!resultDetermined && ((this.bits & ASTNode.InsideExpressionStatement) != 0)) {
            // we only set the return type to be void if this method invocation is used inside an expression statement
            this.binding = scope.environment().updatePolymorphicMethodReturnType((PolymorphicMethodBinding) this.binding, TypeBinding.VOID);
        }
    }
    if ((this.binding.tagBits & TagBits.HasMissingType) != 0) {
        scope.problemReporter().missingTypeInMethod(this, this.binding);
    }
    if (!this.binding.isStatic()) {
        // the "receiver" must not be a type
        if (this.receiverIsType) {
            scope.problemReporter().mustUseAStaticMethod(this, this.binding);
            if (this.actualReceiverType.isRawType() && (this.receiver.bits & ASTNode.IgnoreRawTypeCheck) == 0 && compilerOptions.getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore) {
                scope.problemReporter().rawTypeReference(this.receiver, this.actualReceiverType);
            }
        } else {
            // handle indirect inheritance thru variable secondary bound
            // receiver may receive generic cast, as part of implicit conversion
            TypeBinding oldReceiverType = this.actualReceiverType;
            this.actualReceiverType = this.actualReceiverType.getErasureCompatibleType(this.binding.declaringClass);
            this.receiver.computeConversion(scope, this.actualReceiverType, this.actualReceiverType);
            if (TypeBinding.notEquals(this.actualReceiverType, oldReceiverType) && TypeBinding.notEquals(this.receiver.postConversionType(scope), this.actualReceiverType)) {
                // record need for explicit cast at codegen since receiver could not handle it
                this.bits |= NeedReceiverGenericCast;
            }
        }
    } else {
        // static message invoked through receiver? legal but unoptimal (optional warning).
        if (this.binding.declaringClass.isInterface() && !((isTypeAccess() || this.receiver.isImplicitThis()) && TypeBinding.equalsEquals(this.binding.declaringClass, this.actualReceiverType))) {
            scope.problemReporter().nonStaticOrAlienTypeReceiver(this, this.binding);
        } else if (!(this.receiver.isImplicitThis() || this.receiver.isSuper() || this.receiverIsType)) {
            scope.problemReporter().nonStaticAccessToStaticMethod(this, this.binding);
        }
        if (!this.receiver.isImplicitThis() && TypeBinding.notEquals(this.binding.declaringClass, this.actualReceiverType)) {
            scope.problemReporter().indirectAccessToStaticMethod(this, this.binding);
        }
    }
    if (checkInvocationArguments(scope, this.receiver, this.actualReceiverType, this.binding, this.arguments, this.argumentTypes, this.argsContainCast, this)) {
        this.bits |= ASTNode.Unchecked;
    }
    // -------message send that are known to fail at compile time-----------
    if (this.binding.isAbstract()) {
        if (this.receiver.isSuper()) {
            scope.problemReporter().cannotDireclyInvokeAbstractMethod(this, this.binding);
        }
    // abstract private methods cannot occur nor abstract static............
    }
    if (isMethodUseDeprecated(this.binding, scope, true, this))
        scope.problemReporter().deprecatedMethod(this.binding, this);
    TypeBinding returnType;
    if ((this.bits & ASTNode.Unchecked) != 0 && this.genericTypeArguments == null) {
        // https://bugs.eclipse.org/bugs/show_bug.cgi?id=277643, align with javac on JLS 15.12.2.6
        returnType = this.binding.returnType;
        if (returnType != null) {
            returnType = scope.environment().convertToRawType(returnType.erasure(), true);
        }
    } else {
        returnType = this.binding.returnType;
        if (returnType != null) {
            returnType = returnType.capture(scope, this.sourceStart, this.sourceEnd);
        }
    }
    this.resolvedType = returnType;
    if (this.receiver.isSuper() && compilerOptions.getSeverity(CompilerOptions.OverridingMethodWithoutSuperInvocation) != ProblemSeverities.Ignore) {
        final ReferenceContext referenceContext = scope.methodScope().referenceContext;
        if (referenceContext instanceof AbstractMethodDeclaration) {
            final AbstractMethodDeclaration abstractMethodDeclaration = (AbstractMethodDeclaration) referenceContext;
            MethodBinding enclosingMethodBinding = abstractMethodDeclaration.binding;
            if (enclosingMethodBinding.isOverriding() && CharOperation.equals(this.binding.selector, enclosingMethodBinding.selector) && this.binding.areParametersEqual(enclosingMethodBinding)) {
                abstractMethodDeclaration.bits |= ASTNode.OverridingMethodWithSupercall;
            }
        }
    }
    if (this.receiver.isSuper() && this.actualReceiverType.isInterface()) {
        // 15.12.3 (Java 8)
        scope.checkAppropriateMethodAgainstSupers(this.selector, this.binding, this.argumentTypes, this);
    }
    if (this.typeArguments != null && this.binding.original().typeVariables == Binding.NO_TYPE_VARIABLES) {
        scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(this.binding, this.genericTypeArguments, this.typeArguments);
    }
    return (this.resolvedType.tagBits & TagBits.HasMissingType) == 0 ? this.resolvedType : null;
}
Also used : TypeVariableBinding(org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding) ProblemMethodBinding(org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding) SourceTypeBinding(org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding) TypeBinding(org.eclipse.jdt.internal.compiler.lookup.TypeBinding) MissingTypeBinding(org.eclipse.jdt.internal.compiler.lookup.MissingTypeBinding) PolyTypeBinding(org.eclipse.jdt.internal.compiler.lookup.PolyTypeBinding) RawTypeBinding(org.eclipse.jdt.internal.compiler.lookup.RawTypeBinding) PolymorphicMethodBinding(org.eclipse.jdt.internal.compiler.lookup.PolymorphicMethodBinding) PolyParameterizedGenericMethodBinding(org.eclipse.jdt.internal.compiler.lookup.PolyParameterizedGenericMethodBinding) ParameterizedGenericMethodBinding(org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding) ReferenceBinding(org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) ProblemReferenceBinding(org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding) InferenceVariable(org.eclipse.jdt.internal.compiler.lookup.InferenceVariable) RawTypeBinding(org.eclipse.jdt.internal.compiler.lookup.RawTypeBinding) MissingTypeBinding(org.eclipse.jdt.internal.compiler.lookup.MissingTypeBinding) CompilerOptions(org.eclipse.jdt.internal.compiler.impl.CompilerOptions) ReferenceContext(org.eclipse.jdt.internal.compiler.impl.ReferenceContext) PolymorphicMethodBinding(org.eclipse.jdt.internal.compiler.lookup.PolymorphicMethodBinding) ProblemMethodBinding(org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding) MethodBinding(org.eclipse.jdt.internal.compiler.lookup.MethodBinding) ParameterizedMethodBinding(org.eclipse.jdt.internal.compiler.lookup.ParameterizedMethodBinding) PolyParameterizedGenericMethodBinding(org.eclipse.jdt.internal.compiler.lookup.PolyParameterizedGenericMethodBinding) ParameterizedGenericMethodBinding(org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding)

Example 5 with ReferenceContext

use of org.eclipse.jdt.internal.compiler.impl.ReferenceContext in project bazel-jdt-java-toolchain by salesforce.

the class CompilationResult method computePriority.

private int computePriority(CategorizedProblem problem) {
    final int P_STATIC = 10000;
    final int P_OUTSIDE_METHOD = 40000;
    final int P_FIRST_ERROR = 20000;
    final int P_ERROR = 100000;
    // early problems first
    int priority = 10000 - problem.getSourceLineNumber();
    if (priority < 0)
        priority = 0;
    if (problem.isError()) {
        priority += P_ERROR;
    }
    ReferenceContext context = this.problemsMap == null ? null : this.problemsMap.get(problem);
    if (context != null) {
        if (context instanceof AbstractMethodDeclaration) {
            AbstractMethodDeclaration method = (AbstractMethodDeclaration) context;
            if (method.isStatic()) {
                priority += P_STATIC;
            }
        } else {
            priority += P_OUTSIDE_METHOD;
        }
        if (this.firstErrors.contains(problem)) {
            // if context is null, firstErrors is null too
            priority += P_FIRST_ERROR;
        }
    } else {
        priority += P_OUTSIDE_METHOD;
    }
    return priority;
}
Also used : ReferenceContext(org.eclipse.jdt.internal.compiler.impl.ReferenceContext) AbstractMethodDeclaration(org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration)

Aggregations

ReferenceContext (org.eclipse.jdt.internal.compiler.impl.ReferenceContext)19 AbstractMethodDeclaration (org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration)7 TypeDeclaration (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration)5 BlockScope (org.eclipse.jdt.internal.compiler.lookup.BlockScope)5 MethodBinding (org.eclipse.jdt.internal.compiler.lookup.MethodBinding)5 SourceTypeBinding (org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding)5 LambdaExpression (org.eclipse.jdt.internal.compiler.ast.LambdaExpression)4 ReferenceBinding (org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding)4 CompilationUnitDeclaration (org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration)3 ClassScope (org.eclipse.jdt.internal.compiler.lookup.ClassScope)3 MethodScope (org.eclipse.jdt.internal.compiler.lookup.MethodScope)3 Scope (org.eclipse.jdt.internal.compiler.lookup.Scope)3 TypeBinding (org.eclipse.jdt.internal.compiler.lookup.TypeBinding)3 ASTNode (org.eclipse.jdt.internal.compiler.ast.ASTNode)2 Annotation (org.eclipse.jdt.internal.compiler.ast.Annotation)2 FieldDeclaration (org.eclipse.jdt.internal.compiler.ast.FieldDeclaration)2 AptSourceLocalVariableBinding (org.eclipse.jdt.internal.compiler.lookup.AptSourceLocalVariableBinding)2 CompilationUnitScope (org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope)2 FieldBinding (org.eclipse.jdt.internal.compiler.lookup.FieldBinding)2 InvocationSite (org.eclipse.jdt.internal.compiler.lookup.InvocationSite)2