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; }
public static String[] getUsedVariableNames(ASTNode node) { CompilationUnit root= (CompilationUnit) node.getRoot(); Collection res= (new ScopeAnalyzer(root)).getUsedVariableNames(node.getStartPosition(), node.getLength()); return (String[]) res.toArray(new String[res.size()]); }
public static String[] getUsedVariableNames(ASTNode node) { CompilationUnit root= (CompilationUnit) node.getRoot(); Collection<String> res= (new ScopeAnalyzer(root)).getUsedVariableNames(node.getStartPosition(), node.getLength()); return res.toArray(new String[res.size()]); }
public static String[] getUsedVariableNames(ASTNode node) { CompilationUnit root= (CompilationUnit) node.getRoot(); Collection<String> res= (new ScopeAnalyzer(root)).getUsedVariableNames(node.getStartPosition(), node.getLength()); return res.toArray(new String[res.size()]); }
String proposeLocalName(SimpleName fieldName, CompilationUnit root, IJavaProject javaProject) { // don't propose names that are already in use: Collection<String> variableNames= new ScopeAnalyzer(root).getUsedVariableNames(this.enclosingMethod.getStartPosition(), this.enclosingMethod.getLength()); String[] names = new String[variableNames.size()+1]; variableNames.toArray(names); // don't propose the field name itself, either: String identifier= fieldName.getIdentifier(); names[names.length-1] = identifier; return StubUtility.getLocalNameSuggestions(javaProject, identifier, 0, names)[0]; }
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 String[] getExcludedVariableNames() { if (fExcludedVariableNames == null) { try { IExpressionFragment expr = getSelectedExpression(); Collection<String> takenNames = new ScopeAnalyzer(fCuRewrite.getRoot()).getUsedVariableNames(expr.getStartPosition(), expr.getLength()); fExcludedVariableNames = takenNames.toArray(new String[takenNames.size()]); } catch (JavaModelException e) { fExcludedVariableNames = new String[0]; } } return fExcludedVariableNames; }
private String[] getExcludedVariableNames() { if (fExcludedVariableNames == null) { try { IExpressionFragment expr= getSelectedExpression(); Collection<String> takenNames= new ScopeAnalyzer(fCuRewrite.getRoot()).getUsedVariableNames(expr.getStartPosition(), expr.getLength()); fExcludedVariableNames= takenNames.toArray(new String[takenNames.size()]); } catch (JavaModelException e) { fExcludedVariableNames= new String[0]; } } return fExcludedVariableNames; }
private String[] getExcludedVariableNames() { if (fExcludedVariableNames == null) { try { IExpressionFragment expr= getSelectedExpression(); Collection<String> takenNames= new ScopeAnalyzer(fCuRewrite.getRoot()).getUsedVariableNames(expr.getStartPosition(), expr.getLength()); fExcludedVariableNames= takenNames.toArray(new String[takenNames.size()]); } catch (JavaModelException e) { fExcludedVariableNames= new String[0]; } } return fExcludedVariableNames; }
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 String[] getExcludedVariableNames() { if (fExcludedVariableNames == null) { try { IExpressionFragment expr= getSelectedExpression(); Collection takenNames= new ScopeAnalyzer(fCuRewrite.getRoot()).getUsedVariableNames(expr.getStartPosition(), expr.getLength()); fExcludedVariableNames= (String[]) takenNames.toArray(new String[takenNames.size()]); } catch (JavaModelException e) { fExcludedVariableNames= new String[0]; } } return fExcludedVariableNames; }
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 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(); } }