private SimpleName[] getAllReferences(Block body) { SimpleName[] names= LinkedNodeFinder.findByProblems(body, fOriginalNode); if (names == null) { return new SimpleName[] { fOriginalNode }; } if (names.length > 1) { Arrays.sort(names, new Comparator<SimpleName>() { @Override public int compare(SimpleName s1, SimpleName s2) { return s1.getStartPosition() - s2.getStartPosition(); } }); } return names; }
private SimpleName[] getAllReferences(Block body) { SimpleName[] names= LinkedNodeFinder.findByProblems(body, fOriginalNode); if (names == null) { return new SimpleName[] { fOriginalNode }; } if (names.length > 1) { Arrays.sort(names, new Comparator<SimpleName>() { @Override public int compare(SimpleName s1, SimpleName s2) { return s1.getStartPosition() - s2.getStartPosition(); } }); } return names; }
private SimpleName[] getAllReferences(Block body) { SimpleName[] names= LinkedNodeFinder.findByProblems(body, fOriginalNode); if (names == null) { return new SimpleName[] { fOriginalNode }; } if (names.length > 1) { Arrays.sort(names, new Comparator<SimpleName>() { @Override public int compare(SimpleName s1, SimpleName s2) { return s1.getStartPosition() - s2.getStartPosition(); } }); } return names; }
private SimpleName[] getAllReferences(Block body) { SimpleName[] names= LinkedNodeFinder.findByProblems(body, fOriginalNode); if (names == null) { return new SimpleName[] { fOriginalNode }; } if (names.length > 1) { Arrays.sort(names, new Comparator() { public int compare(Object o1, Object o2) { return ((SimpleName) o1).getStartPosition() - ((SimpleName) o2).getStartPosition(); } }); } return names; }
/** * Find all nodes connected to the given name node. If the node has a binding then all nodes connected * to this binding are returned. If the node has no binding, then all nodes that also miss a binding and have * the same name are returned. * @param root The root of the AST tree to search * @param name The node to find linked nodes for * @return Return */ public static SimpleName[] findByNode(ASTNode root, SimpleName name) { IBinding binding = name.resolveBinding(); if (binding != null) { return findByBinding(root, binding); } SimpleName[] names= findByProblems(root, name); if (names != null) { return names; } int parentKind= name.getParent().getNodeType(); if (parentKind == ASTNode.LABELED_STATEMENT || parentKind == ASTNode.BREAK_STATEMENT || parentKind == ASTNode.CONTINUE_STATEMENT) { ArrayList res= new ArrayList(); LabelFinder nodeFinder= new LabelFinder(name, res); root.accept(nodeFinder); return (SimpleName[]) res.toArray(new SimpleName[res.size()]); } return new SimpleName[] { name }; }
/** * Find all nodes connected to the given name node. If the node has a binding then all nodes connected * to this binding are returned. If the node has no binding, then all nodes that also miss a binding and have * the same name are returned. * @param root The root of the AST tree to search * @param name The node to find linked nodes for * @return Return */ public static SimpleName[] findByNode(ASTNode root, SimpleName name) { IBinding binding = name.resolveBinding(); if (binding != null) { return findByBinding(root, binding); } SimpleName[] names= findByProblems(root, name); if (names != null) { return names; } int parentKind= name.getParent().getNodeType(); if (parentKind == ASTNode.LABELED_STATEMENT || parentKind == ASTNode.BREAK_STATEMENT || parentKind == ASTNode.CONTINUE_STATEMENT) { ArrayList<SimpleName> res= new ArrayList<>(); LabelFinder nodeFinder= new LabelFinder(name, res); root.accept(nodeFinder); return res.toArray(new SimpleName[res.size()]); } return new SimpleName[] { name }; }
/** * Find all nodes connected to the given name node. If the node has a binding then all nodes connected * to this binding are returned. If the node has no binding, then all nodes that also miss a binding and have * the same name are returned. * @param root The root of the AST tree to search * @param name The node to find linked nodes for * @return Return */ public static SimpleName[] findByNode(ASTNode root, SimpleName name) { IBinding binding = name.resolveBinding(); if (binding != null) { return findByBinding(root, binding); } SimpleName[] names= findByProblems(root, name); if (names != null) { return names; } int parentKind= name.getParent().getNodeType(); if (parentKind == ASTNode.LABELED_STATEMENT || parentKind == ASTNode.BREAK_STATEMENT || parentKind == ASTNode.CONTINUE_STATEMENT) { ArrayList<SimpleName> res= new ArrayList<>(); LabelFinder nodeFinder= new LabelFinder(name, res); root.accept(nodeFinder); return res.toArray(new SimpleName[res.size()]); } return new SimpleName[] { name }; }
@Override protected void addEdits(IDocument doc, TextEdit root) throws CoreException { super.addEdits(doc, root); // build a full AST CompilationUnit unit= SharedASTProvider.getAST(getCompilationUnit(), SharedASTProvider.WAIT_YES, null); ASTNode name= NodeFinder.perform(unit, fOffset, fLength); if (name instanceof SimpleName) { SimpleName[] names= LinkedNodeFinder.findByProblems(unit, (SimpleName) name); if (names != null) { for (int i= 0; i < names.length; i++) { SimpleName curr= names[i]; root.addChild(new ReplaceEdit(curr.getStartPosition(), curr.getLength(), fNewName)); } return; } } root.addChild(new ReplaceEdit(fOffset, fLength, fNewName)); } }
@Override protected void addEdits(IDocument doc, TextEdit root) throws CoreException { super.addEdits(doc, root); // build a full AST CompilationUnit unit = CoreASTProvider.getInstance().getAST(getCompilationUnit(), CoreASTProvider.WAIT_YES, null); ASTNode name= NodeFinder.perform(unit, fOffset, fLength); if (name instanceof SimpleName) { SimpleName[] names= LinkedNodeFinder.findByProblems(unit, (SimpleName) name); if (names != null) { for (int i= 0; i < names.length; i++) { SimpleName curr= names[i]; root.addChild(new ReplaceEdit(curr.getStartPosition(), curr.getLength(), fNewName)); } return; } } root.addChild(new ReplaceEdit(fOffset, fLength, fNewName)); } }
@Override protected void addEdits(IDocument doc, TextEdit root) throws CoreException { super.addEdits(doc, root); // build a full AST CompilationUnit unit= SharedASTProviderCore.getAST(getCompilationUnit(), SharedASTProviderCore.WAIT_YES, null); ASTNode name= NodeFinder.perform(unit, fOffset, fLength); if (name instanceof SimpleName) { SimpleName[] names= LinkedNodeFinder.findByProblems(unit, (SimpleName) name); if (names != null) { for (int i= 0; i < names.length; i++) { SimpleName curr= names[i]; root.addChild(new ReplaceEdit(curr.getStartPosition(), curr.getLength(), fNewName)); } return; } } root.addChild(new ReplaceEdit(fOffset, fLength, fNewName)); } }
protected void addEdits(IDocument doc, TextEdit root) throws CoreException { super.addEdits(doc, root); // build a full AST CompilationUnit unit= JavaPlugin.getDefault().getASTProvider().getAST(getCompilationUnit(), ASTProvider.WAIT_YES, null); ASTNode name= NodeFinder.perform(unit, fOffset, fLength); if (name instanceof SimpleName) { SimpleName[] names= LinkedNodeFinder.findByProblems(unit, (SimpleName) name); if (names != null) { for (int i= 0; i < names.length; i++) { SimpleName curr= names[i]; root.addChild(new ReplaceEdit(curr.getStartPosition(), curr.getLength(), fNewName)); } return; } } root.addChild(new ReplaceEdit(fOffset, fLength, fNewName)); } }