private IBinding[] getDeclarationsInScope() { if (fDeclarationsInScope == null) { ScopeAnalyzer analyzer= new ScopeAnalyzer(fCompilationUnit); fDeclarationsInScope= analyzer.getDeclarationsInScope(fPosition, ScopeAnalyzer.METHODS | ScopeAnalyzer.TYPES | ScopeAnalyzer.VARIABLES); } return fDeclarationsInScope; }
private IBinding[] getDeclarationsInScope() { if (fDeclarationsInScope == null) { ScopeAnalyzer analyzer= new ScopeAnalyzer(fCompilationUnit); fDeclarationsInScope= analyzer.getDeclarationsInScope(fPosition, ScopeAnalyzer.METHODS | ScopeAnalyzer.TYPES | ScopeAnalyzer.VARIABLES); } return fDeclarationsInScope; }
private IBinding[] getDeclarationsInScope() { if (fDeclarationsInScope == null) { ScopeAnalyzer analyzer= new ScopeAnalyzer(fCompilationUnit); fDeclarationsInScope= analyzer.getDeclarationsInScope(fPosition, ScopeAnalyzer.METHODS | ScopeAnalyzer.TYPES | ScopeAnalyzer.VARIABLES); } return fDeclarationsInScope; }
private boolean hasConflict(int startPosition, SimpleName name, int flag) { ScopeAnalyzer analyzer= new ScopeAnalyzer(fCompilationUnit); IBinding[] declarationsInScope= analyzer.getDeclarationsInScope(startPosition, flag); for (int i= 0; i < declarationsInScope.length; i++) { IBinding decl= declarationsInScope[i]; if (decl.getName().equals(name.getIdentifier()) && name.resolveBinding() != decl) return true; } return false; } }
private boolean hasConflict(int startPosition, SimpleName name, int flag) { ScopeAnalyzer analyzer= new ScopeAnalyzer(fCompilationUnit); IBinding[] declarationsInScope= analyzer.getDeclarationsInScope(startPosition, flag); for (int i= 0; i < declarationsInScope.length; i++) { IBinding decl= declarationsInScope[i]; if (decl.getName().equals(name.getIdentifier()) && name.resolveBinding() != decl) return true; } return false; } }
private boolean hasConflict(int startPosition, SimpleName name, int flag) { ScopeAnalyzer analyzer= new ScopeAnalyzer(fCompilationUnit); IBinding[] declarationsInScope= analyzer.getDeclarationsInScope(startPosition, flag); for (int i= 0; i < declarationsInScope.length; i++) { IBinding decl= declarationsInScope[i]; if (decl.getName().equals(name.getIdentifier()) && name.resolveBinding() != decl) return true; } return false; } }
/** * Returns a list of local variable names which are visible at the given node. * * @param node the AST node * @return a list of local variable names visible at the given node * @see ScopeAnalyzer#getDeclarationsInScope(int, int) * @since 3.10 */ public static List<String> getVisibleLocalVariablesInScope(ASTNode node) { List<String> variableNames= new ArrayList<>(); CompilationUnit root= (CompilationUnit) node.getRoot(); IBinding[] bindings= new ScopeAnalyzer(root). getDeclarationsInScope(node.getStartPosition(), ScopeAnalyzer.VARIABLES | ScopeAnalyzer.NO_FIELDS | ScopeAnalyzer.CHECK_VISIBILITY); for (IBinding binding : bindings) { variableNames.add(binding.getName()); } return variableNames; }
private static boolean hasConflict(int startPosition, IMethodBinding referredMethodBinding, int flags, CompilationUnit cu) { ScopeAnalyzer analyzer = new ScopeAnalyzer(cu); IBinding[] declarationsInScope = analyzer.getDeclarationsInScope(startPosition, flags); for (int i = 0; i < declarationsInScope.length; i++) { IBinding decl = declarationsInScope[i]; if (decl.getName().equals(referredMethodBinding.getName()) && !referredMethodBinding.getMethodDeclaration().isEqualTo(decl)) { return true; } } return false; }
private static boolean hasConflict(int startPosition, IMethodBinding referredMethodBinding, int flags, CompilationUnit cu) { ScopeAnalyzer analyzer= new ScopeAnalyzer(cu); IBinding[] declarationsInScope= analyzer.getDeclarationsInScope(startPosition, flags); for (int i= 0; i < declarationsInScope.length; i++) { IBinding decl= declarationsInScope[i]; if (decl.getName().equals(referredMethodBinding.getName()) && !referredMethodBinding.getMethodDeclaration().isEqualTo(decl)) return true; } return false; }
private static boolean hasConflict(int startPosition, IMethodBinding referredMethodBinding, int flags, CompilationUnit cu) { ScopeAnalyzer analyzer= new ScopeAnalyzer(cu); IBinding[] declarationsInScope= analyzer.getDeclarationsInScope(startPosition, flags); for (int i= 0; i < declarationsInScope.length; i++) { IBinding decl= declarationsInScope[i]; if (decl.getName().equals(referredMethodBinding.getName()) && !referredMethodBinding.getMethodDeclaration().isEqualTo(decl)) return true; } return false; }
private void initializeExcludedParameterNames(CompilationUnitRewrite cuRewrite) { IBinding[] bindings= new ScopeAnalyzer(cuRewrite.getRoot()).getDeclarationsInScope( fSelectedExpression.getStartPosition(), ScopeAnalyzer.VARIABLES); fExcludedParameterNames= new String[bindings.length]; for (int i= 0; i < fExcludedParameterNames.length; i++) { fExcludedParameterNames[i]= bindings[i].getName(); } }
private void initializeExcludedParameterNames(CompilationUnitRewrite cuRewrite) { IBinding[] bindings= new ScopeAnalyzer(cuRewrite.getRoot()).getDeclarationsInScope( fSelectedExpression.getStartPosition(), ScopeAnalyzer.VARIABLES); fExcludedParameterNames= new String[bindings.length]; for (int i= 0; i < fExcludedParameterNames.length; i++) { fExcludedParameterNames[i]= bindings[i].getName(); } }
private void initializeExcludedParameterNames(CompilationUnitRewrite cuRewrite) { IBinding[] bindings= new ScopeAnalyzer(cuRewrite.getRoot()).getDeclarationsInScope( fSelectedExpression.getStartPosition(), ScopeAnalyzer.VARIABLES); fExcludedParameterNames= new String[bindings.length]; for (int i= 0; i < fExcludedParameterNames.length; i++) { fExcludedParameterNames[i]= bindings[i].getName(); } }
private String[] getExcludedVariableNames() { if (fExcludedVariableNames == null) { try { IBinding[] bindings = new ScopeAnalyzer(fCompilationUnitNode).getDeclarationsInScope(getSelectedExpression().getStartPosition(), ScopeAnalyzer.VARIABLES | ScopeAnalyzer.CHECK_VISIBILITY); fExcludedVariableNames = new String[bindings.length]; for (int i = 0; i < bindings.length; i++) { fExcludedVariableNames[i] = bindings[i].getName(); } } catch (JavaModelException e) { fExcludedVariableNames = new String[0]; } } return fExcludedVariableNames; }
private String[] getExcludedVariableNames() { if (fExcludedVariableNames == null) { try { IBinding[] bindings= new ScopeAnalyzer(fCompilationUnitNode).getDeclarationsInScope(getSelectedExpression().getStartPosition(), ScopeAnalyzer.VARIABLES); fExcludedVariableNames= new String[bindings.length]; for (int i= 0; i < bindings.length; i++) { fExcludedVariableNames[i]= bindings[i].getName(); } } catch (JavaModelException e) { fExcludedVariableNames= new String[0]; } } return fExcludedVariableNames; }
private String[] getExcludedVariableNames() { if (fExcludedVariableNames == null) { try { IBinding[] bindings= new ScopeAnalyzer(fCompilationUnitNode).getDeclarationsInScope(getSelectedExpression().getStartPosition(), ScopeAnalyzer.VARIABLES | ScopeAnalyzer.CHECK_VISIBILITY); fExcludedVariableNames= new String[bindings.length]; for (int i= 0; i < bindings.length; i++) { fExcludedVariableNames[i]= bindings[i].getName(); } } catch (JavaModelException e) { fExcludedVariableNames= new String[0]; } } return fExcludedVariableNames; }
private String[] getExcludedVariableNames() { if (fExcludedVariableNames == null) { try { IBinding[] bindings= new ScopeAnalyzer(fCompilationUnitNode).getDeclarationsInScope(getSelectedExpression().getStartPosition(), ScopeAnalyzer.VARIABLES | ScopeAnalyzer.CHECK_VISIBILITY); fExcludedVariableNames= new String[bindings.length]; for (int i= 0; i < bindings.length; i++) { fExcludedVariableNames[i]= bindings[i].getName(); } } catch (JavaModelException e) { fExcludedVariableNames= new String[0]; } } return fExcludedVariableNames; }
protected Expression computeProposals(AST ast, ITypeBinding returnBinding, int returnOffset, CompilationUnit root, Expression result) { ScopeAnalyzer analyzer= new ScopeAnalyzer(root); IBinding[] bindings= analyzer.getDeclarationsInScope(returnOffset, ScopeAnalyzer.VARIABLES | ScopeAnalyzer.CHECK_VISIBILITY); for (int i= 0; i < bindings.length; i++) { IVariableBinding curr= (IVariableBinding) bindings[i]; ITypeBinding type= curr.getType(); if (type != null && type.isAssignmentCompatible(returnBinding) && testModifier(curr)) { if (result == null) { result= ast.newSimpleName(curr.getName()); } addLinkedPositionProposal(RETURN_EXPRESSION_KEY, curr.getName()); } } return result; }
protected Expression computeProposals(AST ast, ITypeBinding returnBinding, int returnOffset, CompilationUnit root, Expression result) { ScopeAnalyzer analyzer= new ScopeAnalyzer(root); IBinding[] bindings= analyzer.getDeclarationsInScope(returnOffset, ScopeAnalyzer.VARIABLES | ScopeAnalyzer.CHECK_VISIBILITY); for (int i= 0; i < bindings.length; i++) { IVariableBinding curr= (IVariableBinding) bindings[i]; ITypeBinding type= curr.getType(); if (type != null && type.isAssignmentCompatible(returnBinding) && testModifier(curr)) { if (result == null) { result= ast.newSimpleName(curr.getName()); } addLinkedPositionProposal(RETURN_EXPRESSION_KEY, curr.getName(), null); } } return result; }
protected Expression computeProposals(AST ast, ITypeBinding returnBinding, int returnOffset, CompilationUnit root, Expression result) { ScopeAnalyzer analyzer= new ScopeAnalyzer(root); IBinding[] bindings= analyzer.getDeclarationsInScope(returnOffset, ScopeAnalyzer.VARIABLES | ScopeAnalyzer.CHECK_VISIBILITY); for (int i= 0; i < bindings.length; i++) { IVariableBinding curr= (IVariableBinding) bindings[i]; ITypeBinding type= curr.getType(); if (type != null && type.isAssignmentCompatible(returnBinding) && testModifier(curr)) { if (result == null) { result= ast.newSimpleName(curr.getName()); } addLinkedPositionProposal(RETURN_EXPRESSION_KEY, curr.getName(), null); } } return result; }