@Override public boolean hasDefaultNullnessFor(int location, int sourceStart) { int nonNullByDefaultValue = localNonNullByDefaultValue(sourceStart); if(nonNullByDefaultValue != 0) { return (nonNullByDefaultValue & location) != 0; } AbstractMethodDeclaration referenceMethod = referenceMethod(); if (referenceMethod != null) { MethodBinding binding = referenceMethod.binding; if (binding != null && binding.defaultNullness != 0) { return (binding.defaultNullness & location) != 0; } } return this.parent.hasDefaultNullnessFor(location, sourceStart); } @Override
@Override public boolean hasDefaultNullnessFor(int location, int sourceStart) { int nonNullByDefaultValue = localNonNullByDefaultValue(sourceStart); if(nonNullByDefaultValue != 0) { return (nonNullByDefaultValue & location) != 0; } AbstractMethodDeclaration referenceMethod = referenceMethod(); if (referenceMethod != null) { MethodBinding binding = referenceMethod.binding; if (binding != null && binding.defaultNullness != 0) { return (binding.defaultNullness & location) != 0; } } return this.parent.hasDefaultNullnessFor(location, sourceStart); } @Override
@Override public Binding checkRedundantDefaultNullness(int nullBits, int sourceStart) { Binding target = localCheckRedundantDefaultNullness(nullBits, sourceStart); if (target != null) { return target; } AbstractMethodDeclaration referenceMethod = referenceMethod(); if (referenceMethod != null) { MethodBinding binding = referenceMethod.binding; if (binding != null && binding.defaultNullness != 0) { return (binding.defaultNullness == nullBits) ? binding : null; } } return this.parent.checkRedundantDefaultNullness(nullBits, sourceStart); } public boolean shouldCheckAPILeaks(ReferenceBinding declaringClass, boolean memberIsPublic) {
@Override public Binding checkRedundantDefaultNullness(int nullBits, int sourceStart) { Binding target = localCheckRedundantDefaultNullness(nullBits, sourceStart); if (target != null) { return target; } AbstractMethodDeclaration referenceMethod = referenceMethod(); if (referenceMethod != null) { MethodBinding binding = referenceMethod.binding; if (binding != null && binding.defaultNullness != 0) { return (binding.defaultNullness == nullBits) ? binding : null; } } return this.parent.checkRedundantDefaultNullness(nullBits, sourceStart); } public boolean shouldCheckAPILeaks(ReferenceBinding declaringClass, boolean memberIsPublic) {
void checkAgainstNullAnnotation(BlockScope scope, FlowContext flowContext, int nullStatus) { if (nullStatus != FlowInfo.NON_NULL) { // if we can't prove non-null check against declared null-ness of the enclosing method: long tagBits; MethodBinding methodBinding; try { methodBinding = scope.methodScope().referenceMethod().binding; tagBits = methodBinding.tagBits; } catch (NullPointerException npe) { // chain of references in try-block has several potential nulls; // any null means we cannot perform the following check return; } if ((tagBits & TagBits.AnnotationNonNull) != 0) { flowContext.recordNullityMismatch(scope, this.expression, this.expression.resolvedType, methodBinding.returnType, nullStatus); } } }
public LocalTypeBinding(ClassScope scope, SourceTypeBinding enclosingType, CaseStatement switchCase) { super( new char[][] {CharOperation.concat(LocalTypeBinding.LocalTypePrefix, scope.referenceContext.name)}, scope, enclosingType); TypeDeclaration typeDeclaration = scope.referenceContext; if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) { this.tagBits |= TagBits.AnonymousTypeMask; } else { this.tagBits |= TagBits.LocalTypeMask; } this.enclosingCase = switchCase; this.sourceStart = typeDeclaration.sourceStart; MethodScope methodScope = scope.enclosingMethodScope(); AbstractMethodDeclaration methodDeclaration = methodScope.referenceMethod(); if (methodDeclaration != null) { this.enclosingMethod = methodDeclaration.binding; } }
public LocalTypeBinding(ClassScope scope, SourceTypeBinding enclosingType, CaseStatement switchCase) { super( new char[][] {CharOperation.concat(LocalTypeBinding.LocalTypePrefix, scope.referenceContext.name)}, scope, enclosingType); TypeDeclaration typeDeclaration = scope.referenceContext; if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) { this.tagBits |= TagBits.AnonymousTypeMask; } else { this.tagBits |= TagBits.LocalTypeMask; } this.enclosingCase = switchCase; this.sourceStart = typeDeclaration.sourceStart; MethodScope methodScope = scope.enclosingMethodScope(); AbstractMethodDeclaration methodDeclaration = methodScope.referenceMethod(); if (methodDeclaration != null) { this.enclosingMethod = methodDeclaration.binding; } }
public LocalTypeBinding(ClassScope scope, SourceTypeBinding enclosingType, CaseStatement switchCase, ReferenceBinding anonymousOriginalSuperType) { super( new char[][] {CharOperation.concat(LocalTypeBinding.LocalTypePrefix, scope.referenceContext.name)}, scope, enclosingType); TypeDeclaration typeDeclaration = scope.referenceContext; if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) { this.tagBits |= TagBits.AnonymousTypeMask; } else { this.tagBits |= TagBits.LocalTypeMask; } this.enclosingCase = switchCase; this.sourceStart = typeDeclaration.sourceStart; MethodScope methodScope = scope.enclosingMethodScope(); AbstractMethodDeclaration methodDeclaration = methodScope.referenceMethod(); if (methodDeclaration != null) { this.enclosingMethod = methodDeclaration.binding; } }
public void createBinding(MethodScope scope, TypeBinding typeBinding) { if (this.binding == null) { // for default constructors and fake implementation of abstract methods this.binding = new LocalVariableBinding(this, typeBinding, this.modifiers, true /*isArgument*/); } else if (!this.binding.type.isValidBinding()) { AbstractMethodDeclaration methodDecl = scope.referenceMethod(); if (methodDecl != null) { MethodBinding methodBinding = methodDecl.binding; if (methodBinding != null) { methodBinding.tagBits |= TagBits.HasUnresolvedArguments; } } } resolveAnnotations(scope, this.annotations, this.binding); this.binding.declaration = this; }
/** * Resolve without warnings */ public void resolve(BlockScope scope, boolean warn, boolean considerParamRefAsUsage) { LocalVariableBinding variableBinding = scope.findVariable(this.token); if (variableBinding != null && variableBinding.isValidBinding() && ((variableBinding.tagBits & TagBits.IsArgument) != 0)) { this.binding = variableBinding; if (considerParamRefAsUsage) { variableBinding.useFlag = LocalVariableBinding.USED; } return; } if (warn) { try { MethodScope methScope = (MethodScope) scope; scope.problemReporter().javadocUndeclaredParamTagName(this.token, this.sourceStart, this.sourceEnd, methScope.referenceMethod().modifiers); } catch (Exception e) { scope.problemReporter().javadocUndeclaredParamTagName(this.token, this.sourceStart, this.sourceEnd, -1); } } }
public TypeBinding createBinding(MethodScope scope, TypeBinding typeBinding) { if (this.binding == null) { // for default constructors and fake implementation of abstract methods this.binding = new LocalVariableBinding(this, typeBinding, this.modifiers, scope); } else if (!this.binding.type.isValidBinding()) { AbstractMethodDeclaration methodDecl = scope.referenceMethod(); if (methodDecl != null) { MethodBinding methodBinding = methodDecl.binding; if (methodBinding != null) { methodBinding.tagBits |= TagBits.HasUnresolvedArguments; } } } if ((this.binding.tagBits & TagBits.AnnotationResolved) == 0) { resolveAnnotations(scope, this.annotations, this.binding, true); if (scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_8) { Annotation.isTypeUseCompatible(this.type, scope, this.annotations); scope.validateNullAnnotation(this.binding.tagBits, this.type, this.annotations); } } this.binding.declaration = this; return this.binding.type; // might have been updated during resolveAnnotations (for typeAnnotations) }
/** * Resolve without warnings */ public void resolve(BlockScope scope, boolean warn, boolean considerParamRefAsUsage) { LocalVariableBinding variableBinding = scope.findVariable(this.token); if (variableBinding != null && variableBinding.isValidBinding() && ((variableBinding.tagBits & TagBits.IsArgument) != 0)) { this.binding = variableBinding; if (considerParamRefAsUsage) { variableBinding.useFlag = LocalVariableBinding.USED; } return; } if (warn) { try { MethodScope methScope = (MethodScope) scope; scope.problemReporter().javadocUndeclaredParamTagName(this.token, this.sourceStart, this.sourceEnd, methScope.referenceMethod().modifiers); } catch (Exception e) { scope.problemReporter().javadocUndeclaredParamTagName(this.token, this.sourceStart, this.sourceEnd, -1); } } }
/** * Resolve without warnings */ public void resolve(BlockScope scope, boolean warn, boolean considerParamRefAsUsage) { LocalVariableBinding variableBinding = scope.findVariable(this.token); if (variableBinding != null && variableBinding.isValidBinding() && ((variableBinding.tagBits & TagBits.IsArgument) != 0)) { this.binding = variableBinding; if (considerParamRefAsUsage) { variableBinding.useFlag = LocalVariableBinding.USED; } return; } if (warn) { try { MethodScope methScope = (MethodScope) scope; scope.problemReporter().javadocUndeclaredParamTagName(this.token, this.sourceStart, this.sourceEnd, methScope.referenceMethod().modifiers); } catch (Exception e) { scope.problemReporter().javadocUndeclaredParamTagName(this.token, this.sourceStart, this.sourceEnd, -1); } } }
public TypeBinding createBinding(MethodScope scope, TypeBinding typeBinding) { if (this.binding == null) { // for default constructors and fake implementation of abstract methods this.binding = new LocalVariableBinding(this, typeBinding, this.modifiers, scope); } else if (!this.binding.type.isValidBinding()) { AbstractMethodDeclaration methodDecl = scope.referenceMethod(); if (methodDecl != null) { MethodBinding methodBinding = methodDecl.binding; if (methodBinding != null) { methodBinding.tagBits |= TagBits.HasUnresolvedArguments; } } } if ((this.binding.tagBits & TagBits.AnnotationResolved) == 0) { resolveAnnotations(scope, this.annotations, this.binding, true); if (scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_8) { Annotation.isTypeUseCompatible(this.type, scope, this.annotations); scope.validateNullAnnotation(this.binding.tagBits, this.type, this.annotations); } } this.binding.declaration = this; return this.binding.type; // might have been updated during resolveAnnotations (for typeAnnotations) }
/** * Resolve without warnings */ public void resolve(BlockScope scope, boolean warn, boolean considerParamRefAsUsage) { LocalVariableBinding variableBinding = scope.findVariable(this.token); if (variableBinding != null && variableBinding.isValidBinding() && ((variableBinding.tagBits & TagBits.IsArgument) != 0)) { this.binding = variableBinding; if (considerParamRefAsUsage) { variableBinding.useFlag = LocalVariableBinding.USED; } return; } if (warn) { try { MethodScope methScope = (MethodScope) scope; scope.problemReporter().javadocUndeclaredParamTagName(this.token, this.sourceStart, this.sourceEnd, methScope.referenceMethod().modifiers); } catch (Exception e) { scope.problemReporter().javadocUndeclaredParamTagName(this.token, this.sourceStart, this.sourceEnd, -1); } } }
/** * Resolve without warnings */ public void resolve(BlockScope scope, boolean warn, boolean considerParamRefAsUsage) { LocalVariableBinding variableBinding = scope.findVariable(this.token); if (variableBinding != null && variableBinding.isValidBinding() && ((variableBinding.tagBits & TagBits.IsArgument) != 0)) { this.binding = variableBinding; if (considerParamRefAsUsage) { variableBinding.useFlag = LocalVariableBinding.USED; } return; } if (warn) { try { MethodScope methScope = (MethodScope) scope; scope.problemReporter().javadocUndeclaredParamTagName(this.token, this.sourceStart, this.sourceEnd, methScope.referenceMethod().modifiers); } catch (Exception e) { scope.problemReporter().javadocUndeclaredParamTagName(this.token, this.sourceStart, this.sourceEnd, -1); } } }
/** * Resolve without warnings */ public void resolve(BlockScope scope, boolean warn, boolean considerParamRefAsUsage) { LocalVariableBinding variableBinding = scope.findVariable(this.token); if (variableBinding != null && variableBinding.isValidBinding() && ((variableBinding.tagBits & TagBits.IsArgument) != 0)) { this.binding = variableBinding; if (considerParamRefAsUsage) { variableBinding.useFlag = LocalVariableBinding.USED; } return; } if (warn) { try { MethodScope methScope = (MethodScope) scope; scope.problemReporter().javadocUndeclaredParamTagName(this.token, this.sourceStart, this.sourceEnd, methScope.referenceMethod().modifiers); } catch (Exception e) { scope.problemReporter().javadocUndeclaredParamTagName(this.token, this.sourceStart, this.sourceEnd, -1); } } }
public TypeBinding createBinding(MethodScope scope, TypeBinding typeBinding) { if (this.binding == null) { // for default constructors and fake implementation of abstract methods this.binding = new LocalVariableBinding(this, typeBinding, this.modifiers, scope); } else if (!this.binding.type.isValidBinding()) { AbstractMethodDeclaration methodDecl = scope.referenceMethod(); if (methodDecl != null) { MethodBinding methodBinding = methodDecl.binding; if (methodBinding != null) { methodBinding.tagBits |= TagBits.HasUnresolvedArguments; } } } if ((this.binding.tagBits & TagBits.AnnotationResolved) == 0) { resolveAnnotations(scope, this.annotations, this.binding, true); if (scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_8) { Annotation.isTypeUseCompatible(this.type, scope, this.annotations); scope.validateNullAnnotation(this.binding.tagBits, this.type, this.annotations); } } this.binding.declaration = this; return this.binding.type; // might have been updated during resolveAnnotations (for typeAnnotations) }
/** * Resolve without warnings */ public void resolve(BlockScope scope, boolean warn, boolean considerParamRefAsUsage) { LocalVariableBinding variableBinding = scope.findVariable(this.token); if (variableBinding != null && variableBinding.isValidBinding() && ((variableBinding.tagBits & TagBits.IsArgument) != 0)) { this.binding = variableBinding; if (considerParamRefAsUsage) { variableBinding.useFlag = LocalVariableBinding.USED; } return; } if (warn) { try { MethodScope methScope = (MethodScope) scope; scope.problemReporter().javadocUndeclaredParamTagName(this.token, this.sourceStart, this.sourceEnd, methScope.referenceMethod().modifiers); } catch (Exception e) { scope.problemReporter().javadocUndeclaredParamTagName(this.token, this.sourceStart, this.sourceEnd, -1); } } }
/** * Resolve without warnings */ public void resolve(BlockScope scope, boolean warn, boolean considerParamRefAsUsage) { LocalVariableBinding variableBinding = scope.findVariable(this.token); if (variableBinding != null && variableBinding.isValidBinding() && ((variableBinding.tagBits & TagBits.IsArgument) != 0)) { this.binding = variableBinding; if (considerParamRefAsUsage) { variableBinding.useFlag = LocalVariableBinding.USED; } return; } if (warn) { try { MethodScope methScope = (MethodScope) scope; scope.problemReporter().javadocUndeclaredParamTagName(this.token, this.sourceStart, this.sourceEnd, methScope.referenceMethod().modifiers); } catch (Exception e) { scope.problemReporter().javadocUndeclaredParamTagName(this.token, this.sourceStart, this.sourceEnd, -1); } } }