private static ASTNode[] getReferenceNodesIn(CompilationUnit cuNode, Map<ICompilationUnit, SearchMatch[]> references, ICompilationUnit cu) { SearchMatch[] results= references.get(cu); if (results == null) return new ASTNode[0]; return ASTNodeSearchUtil.getAstNodes(results, cuNode); }
private static ASTNode[] getReferenceNodesIn(CompilationUnit cuNode, Map references, ICompilationUnit cu) { SearchMatch[] results= (SearchMatch[]) references.get(cu); if (results == null) return new ASTNode[0]; return ASTNodeSearchUtil.getAstNodes(results, cuNode); }
private static ASTNode[] getReferenceNodesIn(CompilationUnit cuNode, Map<ICompilationUnit, SearchMatch[]> references, ICompilationUnit cu) { SearchMatch[] results= references.get(cu); if (results == null) return new ASTNode[0]; return ASTNodeSearchUtil.getAstNodes(results, cuNode); }
private List<ITypeConstraint> getConstraints(ICompilationUnit unit) { if (fConstraintCache.containsKey(unit)) return fConstraintCache.get(unit); CompilationUnit cu= ASTCreator.createAST(unit, null); // only generate type constraints for relevant MethodDeclaration subtrees if (fMethodBinding != null && fCuToSearchResultGroup.containsKey(unit)){ SearchResultGroup group= fCuToSearchResultGroup.get(unit); ASTNode[] nodes= ASTNodeSearchUtil.getAstNodes(group.getSearchResults(), cu); for (int i=0; i < nodes.length; i++){ ASTNode node = nodes[i]; if (fMethodBinding != null){ // find MethodDeclaration above it in the tree ASTNode n= node; while (n != null && !(n instanceof MethodDeclaration)) { n = n.getParent(); } MethodDeclaration md= (MethodDeclaration) n; if (md != null) md.accept(fCollector); } } } else { cu.accept(fCollector); } List<ITypeConstraint> constraints= Arrays.asList(fCollector.getConstraints()); fConstraintCache.put(unit, constraints); return constraints; }
private List/*<ITypeConstraint>*/ getConstraints(ICompilationUnit unit) { if (fConstraintCache.containsKey(unit)) return (List) fConstraintCache.get(unit); CompilationUnit cu= ASTCreator.createAST(unit, null); // only generate type constraints for relevant MethodDeclaration subtrees if (fMethodBinding != null && fCuToSearchResultGroup.containsKey(unit)){ SearchResultGroup group= (SearchResultGroup) fCuToSearchResultGroup.get(unit); ASTNode[] nodes= ASTNodeSearchUtil.getAstNodes(group.getSearchResults(), cu); for (int i=0; i < nodes.length; i++){ ASTNode node = nodes[i]; if (fMethodBinding != null){ // find MethodDeclaration above it in the tree ASTNode n= node; while (!(n instanceof MethodDeclaration)){ n = n.getParent(); } MethodDeclaration md = (MethodDeclaration)n; md.accept(fCollector); } } } else { cu.accept(fCollector); } List/*<ITypeConstraint>*/ constraints= Arrays.asList(fCollector.getConstraints()); fConstraintCache.put(unit, constraints); return constraints; }
private List<ITypeConstraint> getConstraints(ICompilationUnit unit) { if (fConstraintCache.containsKey(unit)) return fConstraintCache.get(unit); CompilationUnit cu= ASTCreator.createAST(unit, null); // only generate type constraints for relevant MethodDeclaration subtrees if (fMethodBinding != null && fCuToSearchResultGroup.containsKey(unit)){ SearchResultGroup group= fCuToSearchResultGroup.get(unit); ASTNode[] nodes= ASTNodeSearchUtil.getAstNodes(group.getSearchResults(), cu); for (int i=0; i < nodes.length; i++){ ASTNode node = nodes[i]; if (fMethodBinding != null){ // find MethodDeclaration above it in the tree ASTNode n= node; while (n != null && !(n instanceof MethodDeclaration)) { n = n.getParent(); } MethodDeclaration md= (MethodDeclaration) n; if (md != null) md.accept(fCollector); } } } else { cu.accept(fCollector); } List<ITypeConstraint> constraints= Arrays.asList(fCollector.getConstraints()); fConstraintCache.put(unit, constraints); return constraints; }
final SearchResultGroup group= (SearchResultGroup) groups.get(unit); if (group != null) { final ASTNode[] nodes= ASTNodeSearchUtil.getAstNodes(group.getSearchResults(), node); try { getMethodReferencingCompilationUnits(units, nodes);
final SearchResultGroup group= groups.get(unit); if (group != null) { final ASTNode[] nodes= ASTNodeSearchUtil.getAstNodes(group.getSearchResults(), node); try { getMethodReferencingCompilationUnits(units, nodes);
final SearchResultGroup group= groups.get(unit); if (group != null) { final ASTNode[] nodes= ASTNodeSearchUtil.getAstNodes(group.getSearchResults(), node); try { getMethodReferencingCompilationUnits(units, nodes);
protected RefactoringStatus checkConstructorCalls(final IType type, final IProgressMonitor monitor) throws JavaModelException { try { monitor.beginTask(RefactoringCoreMessages.PullUpRefactoring_checking, 2); final RefactoringStatus result= new RefactoringStatus(); final SearchResultGroup[] groups= ConstructorReferenceFinder.getConstructorReferences(type, fOwner, new SubProgressMonitor(monitor, 1), result); final String message= Messages.format(RefactoringCoreMessages.HierarchyRefactoring_gets_instantiated, new Object[] { JavaElementLabels.getTextLabel(type, JavaElementLabels.ALL_FULLY_QUALIFIED)}); ICompilationUnit unit= null; for (int index= 0; index < groups.length; index++) { unit= groups[index].getCompilationUnit(); if (unit != null) { final CompilationUnit cuNode= RefactoringASTParser.parseWithASTProvider(unit, false, new SubProgressMonitor(monitor, 1)); final ASTNode[] references= ASTNodeSearchUtil.getAstNodes(groups[index].getSearchResults(), cuNode); ASTNode node= null; for (int offset= 0; offset < references.length; offset++) { node= references[offset]; if ((node instanceof ClassInstanceCreation) || ConstructorReferenceFinder.isImplicitConstructorReferenceNodeInClassCreations(node)) { final RefactoringStatusContext context= JavaStatusContext.create(unit, node); result.addError(message, context); } } } } return result; } finally { monitor.done(); } }
protected RefactoringStatus checkConstructorCalls(final IType type, final IProgressMonitor monitor) throws JavaModelException { try { monitor.beginTask(RefactoringCoreMessages.PullUpRefactoring_checking, 2); final RefactoringStatus result= new RefactoringStatus(); final SearchResultGroup[] groups= ConstructorReferenceFinder.getConstructorReferences(type, fOwner, new SubProgressMonitor(monitor, 1), result); final String message= Messages.format(RefactoringCoreMessages.HierarchyRefactoring_gets_instantiated, new Object[] { JavaElementLabels.getTextLabel(type, JavaElementLabels.ALL_FULLY_QUALIFIED)}); ICompilationUnit unit= null; for (int index= 0; index < groups.length; index++) { unit= groups[index].getCompilationUnit(); if (unit != null) { final CompilationUnit cuNode= RefactoringASTParser.parseWithASTProvider(unit, false, new SubProgressMonitor(monitor, 1)); final ASTNode[] references= ASTNodeSearchUtil.getAstNodes(groups[index].getSearchResults(), cuNode); ASTNode node= null; for (int offset= 0; offset < references.length; offset++) { node= references[offset]; if ((node instanceof ClassInstanceCreation) || ConstructorReferenceFinder.isImplicitConstructorReferenceNodeInClassCreations(node)) { final RefactoringStatusContext context= JavaStatusContext.create(unit, node); result.addError(message, context); } } } } return result; } finally { monitor.done(); } }
protected RefactoringStatus checkConstructorCalls(final IType type, final IProgressMonitor monitor) throws JavaModelException { try { monitor.beginTask(RefactoringCoreMessages.PullUpRefactoring_checking, 2); final RefactoringStatus result= new RefactoringStatus(); final SearchResultGroup[] groups= ConstructorReferenceFinder.getConstructorReferences(type, fOwner, new SubProgressMonitor(monitor, 1), result); final String message= Messages.format(RefactoringCoreMessages.HierarchyRefactoring_gets_instantiated, new Object[] { JavaElementLabels.getTextLabel(type, JavaElementLabels.ALL_FULLY_QUALIFIED)}); ICompilationUnit unit= null; for (int index= 0; index < groups.length; index++) { unit= groups[index].getCompilationUnit(); if (unit != null) { final CompilationUnit cuNode= RefactoringASTParser.parseWithASTProvider(unit, false, new SubProgressMonitor(monitor, 1)); final ASTNode[] references= ASTNodeSearchUtil.getAstNodes(groups[index].getSearchResults(), cuNode); ASTNode node= null; for (int offset= 0; offset < references.length; offset++) { node= references[offset]; if ((node instanceof ClassInstanceCreation) || ConstructorReferenceFinder.isImplicitConstructorReferenceNodeInClassCreations(node)) { final RefactoringStatusContext context= JavaStatusContext.create(unit, node); result.addError(message, context); } } } } return result; } finally { monitor.done(); } }