use of com.intellij.refactoring.rename.RenameProcessor in project intellij-community by JetBrains.
the class ResourceBundleTest method doTestRenameResourceBundleEntryFile.
private void doTestRenameResourceBundleEntryFile(String fileNameToRenameBefore, String fileNameToCheckBefore, String fileNameToRenameAfter, String fileNameToCheckAfter) {
final PsiFile toRenameFile = myFixture.addFileToProject(fileNameToRenameBefore, "");
final PsiFile toCheck = myFixture.addFileToProject(fileNameToCheckBefore, "");
final RenameProcessor processor = new RenameProcessor(getProject(), toRenameFile, fileNameToRenameAfter, true, true);
for (AutomaticRenamerFactory factory : Extensions.getExtensions(AutomaticRenamerFactory.EP_NAME)) {
if (factory instanceof ResourceBundleRenamerFactory) {
processor.addRenamerFactory(factory);
}
}
processor.run();
assertEquals(fileNameToCheckAfter, toCheck.getName());
}
use of com.intellij.refactoring.rename.RenameProcessor in project intellij-community by JetBrains.
the class BindingProperty method updateBoundFieldName.
public static void updateBoundFieldName(final RadRootContainer root, final String oldName, final String newName, final String fieldClassName) {
final String classToBind = root.getClassToBind();
if (classToBind == null)
return;
final Project project = root.getProject();
if (newName.length() == 0) {
checkRemoveUnusedField(root, oldName, FormEditingUtil.getNextSaveUndoGroupId(project));
return;
}
final PsiClass aClass = JavaPsiFacade.getInstance(project).findClass(classToBind, GlobalSearchScope.allScope(project));
if (aClass == null) {
return;
}
if (oldName == null) {
if (aClass.findFieldByName(newName, true) == null) {
CreateFieldFix.runImpl(project, root, aClass, fieldClassName, newName, false, FormEditingUtil.getNextSaveUndoGroupId(project));
}
return;
}
final PsiField oldField = aClass.findFieldByName(oldName, true);
if (oldField == null) {
return;
}
if (aClass.findFieldByName(newName, true) != null) {
checkRemoveUnusedField(root, oldName, FormEditingUtil.getNextSaveUndoGroupId(project));
return;
}
if (!isFieldUnreferenced(oldField)) {
final int option = Messages.showYesNoDialog(project, MessageFormat.format(UIDesignerBundle.message("message.rename.field"), oldName, newName), UIDesignerBundle.message("title.rename"), Messages.getQuestionIcon());
if (option != Messages.YES) /*Yes*/
{
return;
}
}
// Commit document before refactoring starts
GuiEditor editor = DesignerToolWindowManager.getInstance(project).getActiveFormEditor();
if (editor != null) {
editor.refreshAndSave(false);
}
PsiDocumentManager.getInstance(project).commitAllDocuments();
if (!CommonRefactoringUtil.checkReadOnlyStatus(project, aClass)) {
return;
}
final RenameProcessor processor = new RenameProcessor(project, oldField, newName, true, true);
processor.run();
}
use of com.intellij.refactoring.rename.RenameProcessor in project intellij-community by JetBrains.
the class PyMakePublicQuickFix method applyFix.
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
PsiElement element = descriptor.getPsiElement();
if (element instanceof PyReferenceExpression) {
final PsiReference reference = element.getReference();
if (reference == null)
return;
element = reference.resolve();
}
if (element instanceof PyTargetExpression) {
final String name = ((PyTargetExpression) element).getName();
if (name == null)
return;
final VirtualFile virtualFile = element.getContainingFile().getVirtualFile();
if (virtualFile != null) {
final String publicName = StringUtil.trimLeading(name, '_');
new RenameProcessor(project, element, publicName, false, false).run();
}
}
}
use of com.intellij.refactoring.rename.RenameProcessor in project smali by JesusFreke.
the class ClassRenameTest method doRename.
private void doRename(String oldQualifiedName, String newName) throws Exception {
PsiClass testClass = myJavaFacade.findClass(oldQualifiedName, GlobalSearchScope.allScope(getProject()));
RenameProcessor processor = new RenameProcessor(getProject(), testClass, newName, false, false);
processor.run();
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
FileDocumentManager.getInstance().saveAllDocuments();
}
use of com.intellij.refactoring.rename.RenameProcessor in project smali by JesusFreke.
the class FieldRenameTest method doRename.
private void doRename(String containingClass, String oldFieldName, String newFieldName) throws Exception {
PsiClass testClass = myJavaFacade.findClass(containingClass, GlobalSearchScope.allScope(getProject()));
PsiField field = testClass.findFieldByName(oldFieldName, false);
RenameProcessor processor = new RenameProcessor(getProject(), field, newFieldName, false, false);
processor.run();
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
FileDocumentManager.getInstance().saveAllDocuments();
}
Aggregations