@Override protected Collection<CsmFile> getRefactoredFiles() { Collection<? extends CsmObject> objs = getRefactoredObjects(); if (objs == null || objs.isEmpty()) { return Collections.emptySet(); } Collection<CsmFile> files = new HashSet<CsmFile>(); CsmFile startFile = getStartCsmFile(); for (CsmObject obj : objs) { Collection<CsmProject> prjs = CsmRefactoringUtils.getRelatedCsmProjects(obj, null); CsmProject[] ar = prjs.toArray(new CsmProject[prjs.size()]); refactoring.getContext().add(ar); files.addAll(getRelevantFiles(startFile, obj, refactoring)); } return files; }
public void run(CompilationController compilationController) throws Exception { compilationController.toPhase(Phase.RESOLVED); Element element = elementHandle.resolve(compilationController); if (element != null && element.getKind() == ElementKind.METHOD) { ExecutableElement executableElement = (ExecutableElement) element; TypeMirror typeMirror = executableElement.getReturnType(); if (typeMirror != null && typeMirror.getKind() == TypeKind.DECLARED) { DeclaredType declaredType = (DeclaredType) typeMirror; TypeElement typeElement = (TypeElement) declaredType.asElement(); if (typeElement.getQualifiedName().toString().equals(finalRefactoringSourceFQN)) { TreePathHandle treePathHandle = TreePathHandle.create(compilationController.getTrees().getPath(element), compilationController); methodRenameRefactoring[0] = new RenameRefactoring(Lookups.fixed(treePathHandle)); methodRenameRefactoring[0].getContext().add(compilationController); } } } } }, true);
public void run(CompilationController compilationController) throws Exception { compilationController.toPhase(Phase.RESOLVED); Element element = elementHandle.resolve(compilationController); if (element != null && element.getKind() == ElementKind.METHOD) { ExecutableElement executableElement = (ExecutableElement) element; TypeMirror typeMirror = executableElement.getReturnType(); if (typeMirror != null && typeMirror.getKind() == TypeKind.DECLARED) { DeclaredType declaredType = (DeclaredType) typeMirror; TypeElement typeElement = (TypeElement) declaredType.asElement(); if (typeElement.getQualifiedName().toString().equals(finalRefactoringSourceFQN)) { TreePathHandle treePathHandle = TreePathHandle.create(compilationController.getTrees().getPath(element), compilationController); methodRenameRefactoring[0] = new RenameRefactoring(Lookups.fixed(treePathHandle)); methodRenameRefactoring[0].getContext().add(compilationController); } } } } }, true);
public void run(CompilationController compilationController) throws Exception { compilationController.toPhase(Phase.RESOLVED); Element element = elementHandle.resolve(compilationController); if (element != null && element.getKind() == ElementKind.METHOD) { ExecutableElement executableElement = (ExecutableElement) element; TypeMirror typeMirror = executableElement.getReturnType(); if (typeMirror != null && typeMirror.getKind() == TypeKind.DECLARED) { DeclaredType declaredType = (DeclaredType) typeMirror; TypeElement typeElement = (TypeElement) declaredType.asElement(); if (typeElement.getQualifiedName().toString().equals(finalRefactoringSourceFQN)) { TreePathHandle treePathHandle = TreePathHandle.create(compilationController.getTrees().getPath(element), compilationController); methodRenameRefactoring[0] = new RenameRefactoring(Lookups.fixed(treePathHandle)); methodRenameRefactoring[0].getContext().add(compilationController); } } } } }, true);
InstanceRenamePlugin(InstaceRenameRefactoring refactoring) { myRefactoring = refactoring; refactoring.setPlugin( this ); Lookup lookup = refactoring.getRefactoringSource(); Collection<? extends TreePathHandle> collection = lookup.lookupAll( TreePathHandle.class ); Lookup methodLookup =null; Lookup fieldLookup =null; for (TreePathHandle treePathHandle : collection) { if ( treePathHandle.getKind() == Kind.METHOD ){ methodLookup = Lookups.singleton( treePathHandle ); } else if ( treePathHandle.getKind() == Kind.VARIABLE ){ fieldLookup = Lookups.singleton( treePathHandle ); } } if ( methodLookup != null ){ myMethodRenameRefactoring = new RenameRefactoring( methodLookup ); myMethodRenameRefactoring.getContext().add( InstaceRenameRefactoring.FLAG ); } if ( fieldLookup != null ){ myFieldRenameRefactoring = new RenameRefactoring( fieldLookup ); myFieldRenameRefactoring.getContext().add( InstaceRenameRefactoring.FLAG ); } }
public @Override void run(ResultIterator co) throws Exception { if (co.getSnapshot().getMimeType().equals(JsTokenId.JAVASCRIPT_MIME_TYPE)) { JsParseResult rpr = AstUtilities.getParseResult(co.getParserResult()); org.mozilla.nb.javascript.Node root = rpr.getRootNode(); if (root != null) { AnalysisResult ar = rpr.getStructure(); List<? extends AstElement> els = ar.getElements(); if (els.size() > 0) { // TODO - try to find the outermost or most "relevant" module/class in the file? // In Java, we look for a class with the name corresponding to the file. // It's not as simple in Js. AstElement element = null; for (AstElement astElement : els) { if (astElement.getName().equals(co.getSnapshot().getSource().getFileObject().getName())) { element = astElement; } } if (element != null) { org.mozilla.nb.javascript.Node node = element.getNode(); treePathHandle = new JsElementCtx(root, node, element, rpr.getSnapshot().getSource().getFileObject(), rpr); refactoring.getContext().add(co); } } } } } });
methodRenameRefactoring[0].getContext().add(FacesRefactoringsPluginFactory.DELEGATED_REFACTORING); methodRenameRefactoring[0].getContext().add(FacesRefactoringsPluginFactory.DELEGATED_REFACTORING);
javaRenameRefactoring.getContext().add(classpathInfo); javaRenameRefactoring.getContext().add(FacesRefactoringsPluginFactory.DELEGATED_REFACTORING); Problem problem = javaRenameRefactoring.prepare(refactoringSession); if (problem != null) {
methodRenameRefactoring[0].getContext().add(FacesRefactoringsPluginFactory.DELEGATED_REFACTORING); jspRenameRefactoring.getContext().add(FacesRefactoringsPluginFactory.DELEGATED_REFACTORING);