@Override public AnnotationBinding[] getAnnotations() { return this.local.getAnnotations(); } }
public boolean visit(SingleNameReference name, BlockScope skope) { Binding local = skope.getBinding(name.getName(), ReferenceExpression.this); if (local instanceof LocalVariableBinding) { LocalVariableBinding localBinding = (LocalVariableBinding) local; if (!localBinding.isFinal() && !localBinding.isEffectivelyFinal()) { this.accessesnonFinalOuterLocals = true; } } return false; }
public void resolve (BlockScope scope) { // only need the binding, which is used as reference in FlowInfo methods. this.binding = new LocalVariableBinding( this.name, scope.getJavaLangObject(), // dummy, just needs to be a reference type 0, false); this.binding.closeTracker = this; this.binding.declaringScope = scope; this.binding.setConstant(Constant.NotAConstant); this.binding.useFlag = LocalVariableBinding.USED; // use a free slot without assigning it: this.binding.id = scope.registerTrackingVariable(this); }
public void resetSecretLocals() { for (int i = 0, max = this.locals.length; i < max; i++) { LocalVariableBinding localVariableBinding = this.locals[i]; if (localVariableBinding != null && localVariableBinding.isSecret()) { // all other locals are reinitialized inside the computation of their resolved positions localVariableBinding.resetInitializations(); } } } }
this.bits &= ~ASTNode.FirstAssignmentToLocal; if (localBinding.isFinal()) { if ((this.bits & ASTNode.DepthMASK) == 0) { if ((isReachable && isCompound) || !localBinding.isBlankFinal()){ currentScope.problemReporter().cannotAssignToFinalLocal(localBinding, this); } else if (flowInfo.isPotentiallyAssigned(localBinding)) {
final public boolean isPotentiallyAssigned(LocalVariableBinding local) { // final constants are inlined, and thus considered as always initialized if (local.constant() != Constant.NotAConstant) { return true; } return isPotentiallyAssigned(local.id + this.maxFieldCount); }
protected int matchLocalVariable(LocalVariableBinding variable, boolean matchName) { if (variable == null) return INACCURATE_MATCH; if (matchName && !matchesName(this.pattern.name, variable.readableName())) return IMPOSSIBLE_MATCH; return variable.declaration.declarationSourceStart == getLocalVariable().declarationSourceStart ? ACCURATE_MATCH : IMPOSSIBLE_MATCH; } @Override
private void getScopeKey(BlockScope scope, StringBuffer buffer) { int scopeIndex = scope.scopeIndex(); if (scopeIndex != -1) { getScopeKey((BlockScope)scope.parent, buffer); buffer.append('#'); buffer.append(scopeIndex); } }
public void removeVariable(LocalVariableBinding localBinding) { if (localBinding == null) return; if (localBinding.initializationCount > 0) { localBinding.recordInitializationEndPC(this.position); } for (int i = this.visibleLocalsCount - 1; i >= 0; i--) { LocalVariableBinding visibleLocal = this.visibleLocals[i]; if (visibleLocal == localBinding){ this.visibleLocals[i] = null; // this variable is no longer visible afterwards return; } } }
/** * 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 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; }
this.bits &= ~ASTNode.FirstAssignmentToLocal; if (localBinding.isFinal()) { if ((this.bits & ASTNode.DepthMASK) == 0) { if ((isReachable && isCompound) || !localBinding.isBlankFinal()){ currentScope.problemReporter().cannotAssignToFinalLocal(localBinding, this); } else if (flowInfo.isPotentiallyAssigned(localBinding)) {
public void resetSecretLocals() { for (int i = 0, max = this.locals.length; i < max; i++) { LocalVariableBinding localVariableBinding = this.locals[i]; if (localVariableBinding != null && localVariableBinding.isSecret()) { // all other locals are reinitialized inside the computation of their resolved positions localVariableBinding.resetInitializations(); } } } }
final public boolean isPotentiallyAssigned(LocalVariableBinding local) { // final constants are inlined, and thus considered as always initialized if (local.constant() != Constant.NotAConstant) { return true; } return isPotentiallyAssigned(local.id + this.maxFieldCount); }
protected int matchLocalVariable(LocalVariableBinding variable, boolean matchName) { if (variable == null) return INACCURATE_MATCH; if (matchName && !matchesName(this.pattern.name, variable.readableName())) return IMPOSSIBLE_MATCH; return variable.declaration.declarationSourceStart == getLocalVariable().declarationSourceStart ? ACCURATE_MATCH : IMPOSSIBLE_MATCH; } protected int referenceType() {
private void getScopeKey(BlockScope scope, StringBuffer buffer) { int scopeIndex = scope.scopeIndex(); if (scopeIndex != -1) { getScopeKey((BlockScope)scope.parent, buffer); buffer.append('#'); buffer.append(scopeIndex); } }
public void removeVariable(LocalVariableBinding localBinding) { if (localBinding == null) return; if (localBinding.initializationCount > 0) { localBinding.recordInitializationEndPC(this.position); } for (int i = this.visibleLocalsCount - 1; i >= 0; i--) { LocalVariableBinding visibleLocal = this.visibleLocals[i]; if (visibleLocal == localBinding){ this.visibleLocals[i] = null; // this variable is no longer visible afterwards return; } } }
/** * 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); } } }
this.bits &= ~ASTNode.FirstAssignmentToLocal; if (localBinding.isFinal()) { if ((this.bits & ASTNode.DepthMASK) == 0) { if ((isReachable && isCompound) || !localBinding.isBlankFinal()){ currentScope.problemReporter().cannotAssignToFinalLocal(localBinding, this); } else if (flowInfo.isPotentiallyAssigned(localBinding)) {
public void resetSecretLocals() { for (int i = 0, max = this.locals.length; i < max; i++) { LocalVariableBinding localVariableBinding = this.locals[i]; if (localVariableBinding != null && localVariableBinding.isSecret()) { // all other locals are reinitialized inside the computation of their resolved positions localVariableBinding.resetInitializations(); } } } }