private String getNewFQN(){ return RefactoringUtil.renameClass(oldFqn, rename.getNewName()); }
protected List<RenameItem> getAffectedClasses() { String newName = RefactoringUtil.renameClass(clazz, rename.getNewName()); return Collections.<RenameItem>singletonList(new RenameItem(newName, clazz)); }
@Override public Problem checkParameters() { String newName = refactoring.getNewName(); if (newName == null || newName.isEmpty()) { return new Problem(true, NbBundle.getMessage(CPRenameRefactoringPlugin.class, "MSG_Error_ElementEmpty")); //NOI18N } Node element = context.getElement(); if (element != null) { switch (element.type()) { case cp_variable: //todo add some content tests for newName here break; case cp_mixin_name: //todo add some content tests for newName here break; } } return null; }
String getNewName(FileObject file) { if (refactoring instanceof RenameRefactoring) { // return the new name of the file/element return ((RenameRefactoring)refactoring).getNewName(); } else if (refactoring instanceof MoveRefactoring && file != null && containsOriginalFile(file)) { // return full class name of the java file on its new location return getTargetName((MoveRefactoring)refactoring, file.getName()); } return null; }
return rename.getNewName() + "." + JavaIdentifiers.unqualify(fqn); final String prefix = FileUtil.getRelativePath(root, folder.getParent()).replace('/','.'); final String oldName = buildName(prefix, folder.getName()); final String newName = buildName(prefix, rename.getNewName()); final int oldNameIndex = fqn.lastIndexOf(oldName) + oldName.length();
@Override protected Collection<ModificationResult> process(JsParseResult jspr) { RenameTransformer rt = new RenameTransformer(refactoring.getNewName(), allMethods); rt.setWorkingCopy(jspr); rt.scan(); if(rt.diffs.isEmpty()) { return Collections.emptyList(); } else { ModificationResult mr = new ModificationResult(); mr.addDifferences(jspr.getSnapshot().getSource().getFileObject(), rt.diffs); return Collections.singleton(mr); } } };
private void refactorElements(ModificationResult modificationResult, RefactoringElementContext context, Collection<RefactoringElement> elementsToRename, String renameMsg) throws IOException, ParseException { Map<FileObject, List<Difference>> file2diffs = new HashMap<>(); for (RefactoringElement re : elementsToRename) { CloneableEditorSupport editor = GsfUtilities.findCloneableEditorSupport(re.getFile()); Difference diff = new Difference(Difference.Kind.CHANGE, editor.createPositionRef(re.getRange().getStart(), Bias.Forward), editor.createPositionRef(re.getRange().getEnd(), Bias.Backward), re.getName(), refactoring.getNewName(), renameMsg); List<Difference> diffs = file2diffs.get(re.getFile()); if (diffs == null) { diffs = new ArrayList<>(); file2diffs.put(re.getFile(), diffs); } diffs.add(diff); } for (Entry<FileObject, List<Difference>> entry : file2diffs.entrySet()) { modificationResult.addDifferences(entry.getKey(), entry.getValue()); } } }
private void processRefactoredReferences(List<CsmReference> sortedRefs, FileObject fo, CloneableEditorSupport ces, ModificationResult mr) { String newName = refactoring.getNewName(); for (CsmReference ref : sortedRefs) { String oldText = ref.getText().toString(); String newText = CsmRefactoringUtils.getReplaceText(ref, newName, refactoring); if (newText != null) { String descr = CsmRefactoringUtils.getReplaceDescription(ref, refactoring); Difference diff = CsmRefactoringUtils.rename(ref.getStartOffset(), ref.getEndOffset(), ces, oldText, newText, descr); assert diff != null; mr.addDifference(fo, diff); } } }
@Override public void commit() { if (!refElement.isEnabled()) { return; } // This is supposed to run before the original package is renamed. // The package is renamed after "transactions", then form updates // are run. ClassPath cp = ClassPath.getClassPath(resFolder.getPrimaryFile(), ClassPath.SOURCE); FileObject srcRoot = cp.findOwnerRoot(resFolder.getPrimaryFile()); String newName = refactoring.getNewName().replace('.', '/'); try { // the new package folder is not there yet DataFolder targetFolder = DataFolder.findFolder( FileUtil.createFolder(srcRoot, newName)); resFolder.move(targetFolder); } catch (IOException ex) { Exceptions.printStackTrace(ex); } }
if (fileObject != null) { if (FacesRefactoringUtils.isJavaFileObjectOfInterest(fileObject)) { String newName = getRenameRefactoring().getNewName(); if (newName == null) { return new Problem(true, NbBundle.getMessage(FacesJspFileRenameRefactoringPlugin.class, "ERR_NewNameCannotBeNull")); // NOI18N
@Override public Problem fastCheckParameters() { Problem fastCheckProblem = null; String newName = refactoring.getNewName(); final CsmObject refObj = getStartReferenceObject(); String oldName = CsmRefactoringUtils.getSimpleText(refObj); if (oldName.equals(newName)) { fastCheckProblem = createProblem(fastCheckProblem, true, getString("ERR_NameNotChanged")); // NOI18N return fastCheckProblem; } String errorFmtStr = null; if (CsmKindUtilities.isFile(refObj)) { if (!checkFileName(newName)) { errorFmtStr = getString("ERR_InvalidFileName"); //NOI18N } } else if (!CndLexerUtilities.isCppIdentifier(newName)) { errorFmtStr = getString("ERR_InvalidIdentifier"); //NOI18N } if (errorFmtStr != null) { String msg = new MessageFormat(errorFmtStr).format(new Object[]{newName}); fastCheckProblem = createProblem(fastCheckProblem, true, msg); return fastCheckProblem; } return fastCheckProblem; }
String newName = getRenameRefactoring().getNewName(); if (fileObject != null) { if (FacesRefactoringUtils.isFileUnderDocumentRoot(fileObject)) {
newCode = refactoring.getNewName(); // XXX isn't this == our field "newName"?
String oldName = (prefix.length() == 0 ? fileObject.getName() : prefix + "." + fileObject.getName()); String newName = (prefix.length() == 0 ? refactoring.getNewName() : prefix + "." + refactoring.getNewName()); String newName = refactoring.getNewName(); String newFQN = renameClass(oldFQN, refactoring.getNewName()); List <Occurrences.OccurrenceItem> items = Occurrences.getAllOccurrences(project, oldFQN, newFQN); Modifications modification = new Modifications();
String newName = ((RenameRefactoring)refactoring).getNewName(); try { propertiesDO.rename(newName);
JavaSource js = JavaSource.forFileObject(fo); if (js != null) { clazz = SpringRefactorings.getRenamedClassName(treePathHandle, js, refactoring.getNewName()); String oldPackageName = SpringRefactorings.getPackageName(fo); String newPackageName = recursive ? SpringRefactorings.getRenamedPackageName(fo, refactoring.getNewName()) : refactoring.getNewName(); if (oldPackageName != null && newPackageName != null) { Modifications mods = new Modifications();
String newName = refactoring.getNewName(); String oldName = treePathHandle.getSimpleName(); if (oldName == null) {
String newName = getRenameRefactoring().getNewName(); if (fileObject != null) { if (FacesRefactoringUtils.isFileUnderDocumentRoot(fileObject)) {
String newName = getRenameRefactoring().getNewName(); Project fileObjectProject = FileOwnerQuery.getOwner(fileObject); FileObject pageBeanRoot = JsfProjectUtils.getPageBeanRoot(fileObjectProject);
JavaSource js = JavaSource.forFileObject(fo); if (js != null) { prop = SpringRefactorings.getRenamedProperty(treePathHandle, js, refactoring.getNewName());