private IVariableBinding[] removeSelectedDeclarations(IVariableBinding[] bindings) { List<IVariableBinding> result = new ArrayList<>(bindings.length); Selection selection = getSelection(); for (int i = 0; i < bindings.length; i++) { ASTNode decl = ((CompilationUnit) fEnclosingBodyDeclaration.getRoot()).findDeclaringNode(bindings[i]); if (!selection.covers(decl)) { result.add(bindings[i]); } } return result.toArray(new IVariableBinding[result.size()]); }
private IVariableBinding[] removeSelectedDeclarations(IVariableBinding[] bindings) { List<IVariableBinding> result= new ArrayList<>(bindings.length); Selection selection= getSelection(); for (int i= 0; i < bindings.length; i++) { ASTNode decl= ((CompilationUnit)fEnclosingBodyDeclaration.getRoot()).findDeclaringNode(bindings[i]); if (!selection.covers(decl)) result.add(bindings[i]); } return result.toArray(new IVariableBinding[result.size()]); }
private IVariableBinding[] removeSelectedDeclarations(IVariableBinding[] bindings) { List<IVariableBinding> result= new ArrayList<>(bindings.length); Selection selection= getSelection(); for (int i= 0; i < bindings.length; i++) { ASTNode decl= ((CompilationUnit)fEnclosingBodyDeclaration.getRoot()).findDeclaringNode(bindings[i]); if (!selection.covers(decl)) result.add(bindings[i]); } return result.toArray(new IVariableBinding[result.size()]); }
private IVariableBinding[] removeSelectedDeclarations(IVariableBinding[] bindings) { List result= new ArrayList(bindings.length); Selection selection= getSelection(); for (int i= 0; i < bindings.length; i++) { ASTNode decl= ((CompilationUnit)fEnclosingBodyDeclaration.getRoot()).findDeclaringNode(bindings[i]); if (!selection.covers(decl)) result.add(bindings[i]); } return (IVariableBinding[])result.toArray(new IVariableBinding[result.size()]); }
public int getEndVisitSelectionMode(ASTNode node) { int nodeStart= node.getStartPosition(); int nodeEnd= nodeStart + node.getLength(); if (nodeEnd <= fStart) return BEFORE; else if (covers(node)) return SELECTED; else if (nodeEnd >= fExclusiveEnd) return AFTER; return INTERSECTS; }
public int getEndVisitSelectionMode(ASTNode node) { int nodeStart= node.getStartPosition(); int nodeEnd= nodeStart + node.getLength(); if (nodeEnd <= fStart) return BEFORE; else if (covers(node)) return SELECTED; else if (nodeEnd >= fExclusiveEnd) return AFTER; return INTERSECTS; }
public int getEndVisitSelectionMode(ASTNode node) { int nodeStart= node.getStartPosition(); int nodeEnd= nodeStart + node.getLength(); if (nodeEnd <= fStart) return BEFORE; else if (covers(node)) return SELECTED; else if (nodeEnd >= fExclusiveEnd) return AFTER; return INTERSECTS; }
private void handleReferenceToLocal(SimpleName node, IVariableBinding binding) { VariableDeclaration declaration= ASTNodes.findVariableDeclaration(binding, node); if (declaration != null && fSelection.covers(declaration)) addLocalDeclaration(declaration); }
private void handleReferenceToLocal(SimpleName node, IVariableBinding binding) { VariableDeclaration declaration= ASTNodes.findVariableDeclaration(binding, node); if (declaration != null && fSelection.covers(declaration)) addLocalDeclaration(declaration); }
private void handleReferenceToLocal(SimpleName node, IVariableBinding binding) { VariableDeclaration declaration= ASTNodes.findVariableDeclaration(binding, node); if (declaration != null && fSelection.covers(declaration)) addLocalDeclaration(declaration); }
@Override public boolean visit(SimpleName node) { if (fIgnoreBinding != null && Bindings.equals(fIgnoreBinding, node.resolveBinding())) { return false; } if (fIgnoreRange != null && fIgnoreRange.covers(node)) { return false; } fScope.addName(node.getIdentifier()); return false; }
public boolean visit(SimpleName node) { if (fIgnoreBinding != null && Bindings.equals(fIgnoreBinding, node.resolveBinding())) return false; if (fIgnoreRange != null && fIgnoreRange.covers(node)) return false; fScope.addName(node.getIdentifier()); return false; }
@Override public boolean visit(SimpleName node) { if (fIgnoreBinding != null && Bindings.equals(fIgnoreBinding, node.resolveBinding())) return false; if (fIgnoreRange != null && fIgnoreRange.covers(node)) return false; fScope.addName(node.getIdentifier()); return false; }
@Override public boolean visit(SimpleName node) { if (fIgnoreBinding != null && Bindings.equals(fIgnoreBinding, node.resolveBinding())) return false; if (fIgnoreRange != null && fIgnoreRange.covers(node)) return false; fScope.addName(node.getIdentifier()); return false; }
private ITypeBinding[] computeTypeVariables(ITypeBinding[] bindings) { Selection selection= getSelection(); Set<ITypeBinding> result= new HashSet<>(); // first remove all type variables that come from outside of the method // or are covered by the selection CompilationUnit compilationUnit= (CompilationUnit)fEnclosingBodyDeclaration.getRoot(); for (int i= 0; i < bindings.length; i++) { ASTNode decl= compilationUnit.findDeclaringNode(bindings[i]); if (decl == null || (!selection.covers(decl) && decl.getParent() instanceof MethodDeclaration)) result.add(bindings[i]); } // all all type variables which are needed since a local variable uses it for (int i= 0; i < fArguments.length; i++) { IVariableBinding arg= fArguments[i]; ITypeBinding type= arg.getType(); if (type != null && type.isTypeVariable()) { ASTNode decl= compilationUnit.findDeclaringNode(type); if (decl == null || (!selection.covers(decl) && decl.getParent() instanceof MethodDeclaration)) result.add(type); } } return result.toArray(new ITypeBinding[result.size()]); }
@Override public boolean visit(Assignment node) { boolean result= super.visit(node); if ((getSelection().covers(node.getLeftHandSide()) && !getSelection().covers(node.getRightHandSide())) || getSelection().coveredBy(node.getLeftHandSide())) { invalidSelection( RefactoringCoreMessages.ExtractMethodAnalyzer_leftHandSideOfAssignment, JavaStatusContext.create(fCUnit, node)); return false; } return result; }
@Override public boolean visit(Assignment node) { boolean result = super.visit(node); Selection selection = getSelection(); ASTNode selectedNode = NodeFinder.perform(node, selection.getOffset(), selection.getLength()); if ((selectedNode != null && SnippetFinder.isLeftHandSideOfAssignment(selectedNode)) || (selection.covers(node.getLeftHandSide()) && !selection.covers(node.getRightHandSide()))) { invalidSelection(RefactoringCoreMessages.ExtractMethodAnalyzer_leftHandSideOfAssignment, JavaStatusContext.create(fCUnit, node)); return false; } return result; }
@Override public boolean visit(Assignment node) { boolean result= super.visit(node); Selection selection= getSelection(); ASTNode selectedNode= NodeFinder.perform(node, selection.getOffset(), selection.getLength()); if ((selectedNode != null && SnippetFinder.isLeftHandSideOfAssignment(selectedNode)) || (selection.covers(node.getLeftHandSide()) && !selection.covers(node.getRightHandSide()))) { invalidSelection( RefactoringCoreMessages.ExtractMethodAnalyzer_leftHandSideOfAssignment, JavaStatusContext.create(fCUnit, node)); return false; } return result; }
protected boolean visitNode(ASTNode node) { // The selection lies behind the node. if (fSelection.liesOutside(node)) { return false; } else if (fSelection.covers(node)) { if (isFirstNode()) { handleFirstSelectedNode(node); } else { handleNextSelectedNode(node); } return fTraverseSelectedNode; } else if (fSelection.coveredBy(node)) { fLastCoveringNode= node; return true; } else if (fSelection.endsIn(node)) { return handleSelectionEndsIn(node); } // There is a possibility that the user has selected trailing semicolons that don't belong // to the statement. So dive into it to check if sub nodes are fully covered. return true; }
@Override protected boolean visitNode(ASTNode node) { // The selection lies behind the node. if (fSelection.liesOutside(node)) { return false; } else if (fSelection.covers(node)) { if (isFirstNode()) { handleFirstSelectedNode(node); } else { handleNextSelectedNode(node); } return fTraverseSelectedNode; } else if (fSelection.coveredBy(node)) { fLastCoveringNode= node; return true; } else if (fSelection.endsIn(node)) { return handleSelectionEndsIn(node); } // There is a possibility that the user has selected trailing semicolons that don't belong // to the statement. So dive into it to check if sub nodes are fully covered. return true; }