public CPRenameRefactoringUI(RefactoringElementContext context) { this.context = context; Collection<Object> lookupContent = new ArrayList<>(); lookupContent.add(context); this.refactoring = new RenameRefactoring(Lookups.fixed(lookupContent.toArray())); }
RenameRefactoringUI(FileObject jmiObject, String newName, JsElementCtx handle) { if (handle!=null) { this.refactoring = new RenameRefactoring(Lookups.fixed(jmiObject, handle)); } else { this.refactoring = new RenameRefactoring(Lookups.fixed(jmiObject)); } //this.jmiObject = jmiObject; oldName = newName; //[FIXME] this should be oldName of refactored object this.dispOldName = newName; // XXX: parsingapi // ClasspathInfo cpInfo = handle==null?RetoucheUtils.getClasspathInfoFor(jmiObject):RetoucheUtils.getClasspathInfoFor(handle); // if (cpInfo != null) { // refactoring.getContext().add(cpInfo); // } fromListener = true; // Force refresh! this.refactoring.getContext().add(true); }
FacesRenameRefactoringUI(FileObject jspFileObject, String newName) { refactoring = new RenameRefactoring(Lookups.singleton(jspFileObject)); originalName = jspFileObject.getName(); if (newName == null) { dispOldName = oldName = jspFileObject.getName(); } else { dispOldName = oldName = newName; newNameSpecified = 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);
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);
RenameRefactoringUI(NonRecursiveFolder jmiObject, String newName) { this.refactoring = new RenameRefactoring(Lookups.singleton(jmiObject)); // XXX: parsingapi // ClasspathInfo classpath = RetoucheUtils.getClasspathInfoFor(jmiObject.getFolder()); // if (classpath != null) { // refactoring.getContext().add(classpath); // } //this.jmiObject = jmiObject; oldName = newName; //[FIXME] this should be oldName of refactored object this.dispOldName = newName; fromListener = true; pkgRename = true; // Force refresh! this.refactoring.getContext().add(UI.Constants.REQUEST_PREVIEW); }
public RenameRefactoringUI(FileObject file, JsElementCtx handle) { if (handle!=null) { jmiObject = handle; this.refactoring = new RenameRefactoring(Lookups.fixed(file, handle)); //oldName = jmiObject.resolveElement(info).getSimpleName().toString(); oldName = jmiObject.getSimpleName(); } else { this.refactoring = new RenameRefactoring(Lookups.fixed(file)); oldName = file.getName(); } dispOldName = oldName; // XXX: parsingapi // ClasspathInfo cpInfo = handle==null?RetoucheUtils.getClasspathInfoFor(file):RetoucheUtils.getClasspathInfoFor(handle); // if (cpInfo != null) { // refactoring.getContext().add(cpInfo); // } //this(jmiObject, (FileObject) null, true); // Force refresh! this.refactoring.getContext().add(UI.Constants.REQUEST_PREVIEW); }
public RenameRefactoringUI(NonRecursiveFolder file) { this.refactoring = new RenameRefactoring(Lookups.singleton(file)); oldName = RetoucheUtils.getPackageName(file.getFolder()); // XXX: parsingapi // ClasspathInfo classpath = RetoucheUtils.getClasspathInfoFor(file.getFolder()); // if (classpath != null) { // refactoring.getContext().add(classpath); // } dispOldName = oldName; pkgRename = true; //this(jmiObject, (FileObject) null, true); // Force refresh! this.refactoring.getContext().add(UI.Constants.REQUEST_PREVIEW); }
public RenameRefactoringUI(JsElementCtx handle) { this.jmiObject = handle; stripPrefix = handle.getStripPrefix(); this.refactoring = new RenameRefactoring(Lookups.singleton(handle)); //oldName = handle.resolveElement(info).getSimpleName().toString(); oldName = handle.getSimpleName(); // XXX: parsingapi // ClasspathInfo classpath = RetoucheUtils.getClasspathInfoFor(handle); // if (classpath != null) { // refactoring.getContext().add(classpath); // } dispOldName = oldName; //this(jmiObject, (FileObject) null, true); // Force refresh! this.refactoring.getContext().add(UI.Constants.REQUEST_PREVIEW); }
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 RenameRefactoringUI(CsmObject csmObject, String newName) { this.origObject = csmObject; this.dispOldName = this.oldName = CsmRefactoringUtils.getSimpleText(this.origObject); this.newName = newName; this.fromListener = (newName != null); Lookup lkp = null; if (CsmKindUtilities.isFile(csmObject)) { // name is without extension, because later it will be passed to usual rename // refactoring as well which make real file rename and has ability to undo it FileObject fo = CsmUtilities.getFileObject(((CsmFile)csmObject)); if (fo != null) { lkp = Lookups.fixed(csmObject, fo); } } if (lkp == null) { lkp = Lookups.singleton(csmObject); } this.refactoring = new RenameRefactoring(lkp); }
private static void doRenameRefactoring(FormDataObject dao, String newName, TreePathHandle handle) throws IOException { if(handle==null){ //this would only happen if setName were called without the correct component being //selected some how... return; } FormEditorSupport fes = (FormEditorSupport)dao.getFormEditorSupport(); if (fes.isModified()) { fes.saveDocument(); } //ok, so we are now ready to actually setup our RenameRefactoring...we need the element TreePathHandle Lookup rnl = Lookups.singleton(handle); RefactoringSession renameSession = RefactoringSession.create("Change variable name");//NOI18N RenameRefactoring refactoring = new RenameRefactoring(rnl); Problem pre = refactoring.preCheck(); if(pre!=null&&pre.isFatal()){ Logger.getLogger("global").log(Level.WARNING, "There were problems trying to perform the refactoring."); } Problem p = null; if( (!(pre!=null&&pre.isFatal())) && !emptyOrWhite(newName) ){ refactoring.setNewName(newName); p = refactoring.prepare(renameSession); } if( (!(p!=null&&p.isFatal())) && !emptyOrWhite(newName) ){ renameSession.doRefactoring(true); } }
methodRenameRefactoring[0] = new RenameRefactoring(Lookups.fixed(treePathHandle)); methodRenameRefactoring[0].getContext().add(compilationController); FileObject jspFileObject = FacesModel.getJspForJava(refactoringSourcefileObject); if (jspFileObject != null) { RenameRefactoring jspRenameRefactoring = new RenameRefactoring(Lookups.singleton(jspFileObject)); jspRenameRefactoring.setNewName(newName); jspRenameRefactoring.setSearchInComments(getRenameRefactoring().isSearchInComments());
RenameRefactoring javaRenameRefactoring = new RenameRefactoring(Lookups.singleton(javaFileObject)); javaRenameRefactoring.setNewName(newName); javaRenameRefactoring.setSearchInComments(getRenameRefactoring().isSearchInComments());