Search in sources :

Example 16 with RenameProcessor

use of com.intellij.refactoring.rename.RenameProcessor in project smali by JesusFreke.

the class MethodRenameTest method doRename.

private void doRename(String containingClass, String oldMethodName, String newMethodName) throws Exception {
    PsiClass testClass = myJavaFacade.findClass(containingClass, GlobalSearchScope.allScope(getProject()));
    PsiMethod method = testClass.findMethodsByName(oldMethodName, false)[0];
    RenameProcessor processor = new RenameProcessor(getProject(), method, newMethodName, false, false);
    processor.run();
    PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
    FileDocumentManager.getInstance().saveAllDocuments();
}
Also used : RenameProcessor(com.intellij.refactoring.rename.RenameProcessor) PsiMethod(com.intellij.psi.PsiMethod) PsiClass(com.intellij.psi.PsiClass)

Example 17 with RenameProcessor

use of com.intellij.refactoring.rename.RenameProcessor in project android by JetBrains.

the class AndroidMultiModuleRenameTest method testLibraryPackageRename.

// Check that renaming package in a library module would rename corresponding reference in AndroidManifest.xml
public void testLibraryPackageRename() throws Exception {
    final VirtualFile manifestFile = myFixture.copyFileToProject("rename/AndroidManifest_library_before.xml", LIBRARY_PATH + "/src/AndroidManifest.xml");
    myFixture.configureFromExistingVirtualFile(manifestFile);
    // At least one Java source has to be copied for .findPackage to return non-null instance
    myFixture.copyFileToProject("rename/LibraryClass.java", LIBRARY_PATH + "/src/com/works/customization/my/library/LibraryClass.java");
    final PsiPackage aPackage = JavaPsiFacade.getInstance(getProject()).findPackage("com.works.customization.my.library");
    assertNotNull(aPackage);
    new RenameProcessor(getProject(), aPackage, "com.works.customization.my.library2", true, true).run();
    FileDocumentManager.getInstance().saveAllDocuments();
    myFixture.checkResultByFile("rename/AndroidManifest_library_after.xml");
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) RenameProcessor(com.intellij.refactoring.rename.RenameProcessor) PsiPackage(com.intellij.psi.PsiPackage)

Example 18 with RenameProcessor

use of com.intellij.refactoring.rename.RenameProcessor in project android by JetBrains.

the class AndroidRenameTest method doRenameJavaPackage.

private void doRenameJavaPackage(String packageName, String newPackageName) throws Exception {
    final PsiPackage aPackage = JavaPsiFacade.getInstance(getProject()).findPackage(packageName);
    assertNotNull("Package " + packageName + " not found", aPackage);
    new RenameProcessor(getProject(), aPackage, newPackageName, true, true).run();
    FileDocumentManager.getInstance().saveAllDocuments();
}
Also used : RenameProcessor(com.intellij.refactoring.rename.RenameProcessor)

Example 19 with RenameProcessor

use of com.intellij.refactoring.rename.RenameProcessor in project intellij-plugins by JetBrains.

the class FlexHighlightingTest method testAfterRename.

@JSTestOptions({ JSTestOption.WithFlexFacet, JSTestOption.WithGumboSdk })
@SuppressWarnings({ "ConstantConditions" })
public void testAfterRename() throws Exception {
    configureByFile(getBasePath() + "/afterRename.xml");
    XmlNSDescriptor nsDescriptor = ((XmlFile) getFile()).getDocument().getRootTagNSDescriptor();
    assertTrue(nsDescriptor.toString(), nsDescriptor instanceof XmlNSDescriptorImpl);
    doDoTest(true, true);
    new RenameProcessor(getProject(), getFile(), "afterRename.mxml", false, false).run();
    assertEquals("afterRename.mxml", getFile().getName());
    assertFalse(myFile.isValid());
    myFile = myPsiManager.findFile(getFile().getVirtualFile().getParent().findChild("afterRename.mxml"));
    assertTrue(myFile.isValid());
    nsDescriptor = ((XmlFile) getFile()).getDocument().getRootTagNSDescriptor();
    assertTrue(nsDescriptor.toString(), nsDescriptor instanceof FlexMxmlNSDescriptor);
    doDoTest(true, true);
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) RenameProcessor(com.intellij.refactoring.rename.RenameProcessor) XmlFile(com.intellij.psi.xml.XmlFile) FlexMxmlNSDescriptor(com.intellij.javascript.flex.mxml.schema.FlexMxmlNSDescriptor) XmlNSDescriptorImpl(com.intellij.xml.impl.dtd.XmlNSDescriptorImpl)

Example 20 with RenameProcessor

use of com.intellij.refactoring.rename.RenameProcessor in project intellij-community by JetBrains.

the class ProjectViewUpdatingTest method testUpdateProjectView.

public void testUpdateProjectView() throws Exception {
    getProjectTreeStructure().setProviders(new ClassesTreeStructureProvider(myProject), new FormMergerTreeStructureProvider(myProject));
    final AbstractProjectViewPSIPane pane = myStructure.createPane();
    final JTree tree = pane.getTree();
    PlatformTestUtil.assertTreeEqual(tree, "-Project\n" + " +PsiDirectory: updateProjectView\n" + getRootFiles() + " +External Libraries\n");
    final PsiJavaFile classFile = (PsiJavaFile) getContentDirectory().findSubdirectory("src").findSubdirectory("com").findSubdirectory("package1").findFile("Form1.java");
    final PsiClass aClass = classFile.getClasses()[0];
    final PsiFile containingFile = aClass.getContainingFile();
    pane.select(aClass, containingFile.getVirtualFile(), true);
    PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" + " -PsiDirectory: updateProjectView\n" + "  -PsiDirectory: src\n" + "   -PsiDirectory: com\n" + "    -PsiDirectory: package1\n" + "     Class1\n" + "     +Class2.java\n" + "     Class4.java\n" + "     Form2.form\n" + "     -Form:Form1\n" + "      [Form1]\n" + "      Form1.form\n" + getRootFiles() + " +External Libraries\n", true);
    CommandProcessor.getInstance().executeCommand(myProject, () -> new RenameProcessor(myProject, aClass, "Form1_renamed", false, false).run(), null, null);
    PlatformTestUtil.waitForAlarm(600);
    PlatformTestUtil.assertTreeEqual(tree, "-Project\n" + " -PsiDirectory: updateProjectView\n" + "  -PsiDirectory: src\n" + "   -PsiDirectory: com\n" + "    -PsiDirectory: package1\n" + "     Class1\n" + "     +Class2.java\n" + "     Class4.java\n" + "     Form2.form\n" + "     -Form:Form1_renamed\n" + "      Form1.form\n" + "      [Form1_renamed]\n" + getRootFiles() + " +External Libraries\n", true);
    TreeUtil.collapseAll(pane.getTree(), -1);
    PlatformTestUtil.assertTreeEqual(tree, "-Project\n" + " +PsiDirectory: updateProjectView\n" + getRootFiles() + " +External Libraries\n");
    final PsiClass aClass2 = JavaDirectoryService.getInstance().createClass(getContentDirectory().findSubdirectory("src").findSubdirectory("com").findSubdirectory("package1"), "Class6");
    PlatformTestUtil.waitForAlarm(600);
    final PsiFile containingFile2 = aClass2.getContainingFile();
    pane.select(aClass2, containingFile2.getVirtualFile(), true);
    PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" + " -PsiDirectory: updateProjectView\n" + "  -PsiDirectory: src\n" + "   -PsiDirectory: com\n" + "    -PsiDirectory: package1\n" + "     Class1\n" + "     +Class2.java\n" + "     Class4.java\n" + "     [Class6]\n" + "     Form2.form\n" + "     +Form:Form1_renamed\n" + getRootFiles() + " +External Libraries\n", true);
}
Also used : AbstractProjectViewPSIPane(com.intellij.ide.projectView.impl.AbstractProjectViewPSIPane) ClassesTreeStructureProvider(com.intellij.ide.projectView.impl.ClassesTreeStructureProvider) RenameProcessor(com.intellij.refactoring.rename.RenameProcessor) FormMergerTreeStructureProvider(com.intellij.uiDesigner.projectView.FormMergerTreeStructureProvider)

Aggregations

RenameProcessor (com.intellij.refactoring.rename.RenameProcessor)32 PsiElement (com.intellij.psi.PsiElement)10 PsiClass (com.intellij.psi.PsiClass)7 AutomaticRenamerFactory (com.intellij.refactoring.rename.naming.AutomaticRenamerFactory)5 PsiMethod (com.intellij.psi.PsiMethod)3 Project (com.intellij.openapi.project.Project)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 JavaPsiFacade (com.intellij.psi.JavaPsiFacade)2 BuildFile (com.google.idea.blaze.base.lang.buildfile.psi.BuildFile)1 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)1 AbstractProjectViewPSIPane (com.intellij.ide.projectView.impl.AbstractProjectViewPSIPane)1 ClassesTreeStructureProvider (com.intellij.ide.projectView.impl.ClassesTreeStructureProvider)1 FlexMxmlNSDescriptor (com.intellij.javascript.flex.mxml.schema.FlexMxmlNSDescriptor)1 ResourceBundleRenamerFactory (com.intellij.lang.properties.refactoring.rename.ResourceBundleRenamerFactory)1 Editor (com.intellij.openapi.editor.Editor)1 Module (com.intellij.openapi.module.Module)1 DialogBuilder (com.intellij.openapi.ui.DialogBuilder)1 ProperTextRange (com.intellij.openapi.util.ProperTextRange)1 TextRange (com.intellij.openapi.util.TextRange)1 PsiField (com.intellij.psi.PsiField)1