private void recordAssignment( Variable var, boolean isDeclaration, boolean uninitialized, boolean forceVariable, Expression expression) { if (var == null) { return; } if (!isDeclaration && var.isClosureSharedVariable()) { getState().put(var, VariableState.is_var); } VariableState variableState = getState().get(var); if (variableState == null) { variableState = uninitialized ? VariableState.is_uninitialized : VariableState.is_final; if (getTarget(var) instanceof Parameter) { variableState = VariableState.is_var; } } else { variableState = variableState.getNext(); } if (forceVariable) { variableState = VariableState.is_var; } getState().put(var, variableState); if (variableState == VariableState.is_var && callback != null) { callback.variableNotFinal(var, expression); } }
@Override public void visitBlockStatement(final BlockStatement block) { Set<VariableExpression> old = declaredFinalVariables; declaredFinalVariables = new HashSet<VariableExpression>(); super.visitBlockStatement(block); if (callback != null) { Map<Variable, VariableState> state = getState(); for (VariableExpression declaredFinalVariable : declaredFinalVariables) { VariableState variableState = state.get(declaredFinalVariable.getAccessedVariable()); if (variableState == null || variableState != VariableState.is_final) { callback.variableNotAlwaysInitialized(declaredFinalVariable); } } } declaredFinalVariables = old; }