Search in sources :

Example 26 with RenameProcessor

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

the class JavaFXRenameTest method doTest.

private void doTest(final String newName, boolean inline) throws Exception {
    myFixture.configureByFiles(getTestName(true) + ".fxml", getTestName(false) + ".java");
    PsiElement element = TargetElementUtil.findTargetElement(getEditor(), TargetElementUtil.ELEMENT_NAME_ACCEPTED | TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED);
    assertNotNull(element);
    if (inline) {
        CodeInsightTestUtil.doInlineRename(new MemberInplaceRenameHandler(), newName, getEditor(), element);
    } else {
        new RenameProcessor(getProject(), element, newName, true, true).run();
    }
    myFixture.checkResultByFile(getTestName(true) + "_after.fxml");
}
Also used : MemberInplaceRenameHandler(com.intellij.refactoring.rename.inplace.MemberInplaceRenameHandler) RenameProcessor(com.intellij.refactoring.rename.RenameProcessor) PsiElement(com.intellij.psi.PsiElement)

Example 27 with RenameProcessor

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

the class JavaFXRenameTest method testNestedControllerIdFromJava.

public void testNestedControllerIdFromJava() throws Exception {
    myFixture.configureByFiles(getTestName(false) + ".java", getTestName(false) + "Internal.java", getTestName(true) + ".fxml");
    final PsiElement elementAtCaret = myFixture.getElementAtCaret();
    new RenameProcessor(getProject(), elementAtCaret, "newName", false, false).run();
    myFixture.checkResultByFile(getTestName(true) + ".fxml", getTestName(true) + "_after.fxml", false);
    myFixture.checkResultByFile(getTestName(false) + ".java", getTestName(false) + "_after.java", false);
}
Also used : RenameProcessor(com.intellij.refactoring.rename.RenameProcessor) PsiElement(com.intellij.psi.PsiElement)

Example 28 with RenameProcessor

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

the class RenameLocalTest method doTest.

private void doTest(final String newName) throws Exception {
    configureByFile(BASE_PATH + getTestName(false) + ".java");
    PsiElement element = TargetElementUtil.findTargetElement(myEditor, TargetElementUtil.ELEMENT_NAME_ACCEPTED | TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED);
    assertNotNull(element);
    new RenameProcessor(getProject(), element, newName, true, true).run();
    checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
}
Also used : RenameProcessor(com.intellij.refactoring.rename.RenameProcessor) PsiElement(com.intellij.psi.PsiElement)

Example 29 with RenameProcessor

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

the class RenameMethodMultiTest method doAutomaticRenameMethod.

private void doAutomaticRenameMethod(final String className, final String methodSignature, final String newName) throws Exception {
    doTest((rootDir, rootAfter) -> {
        final JavaPsiFacade manager = getJavaFacade();
        final PsiClass aClass = manager.findClass(className, GlobalSearchScope.moduleScope(myModule));
        assertNotNull(aClass);
        final PsiMethod methodBySignature = aClass.findMethodBySignature(manager.getElementFactory().createMethodFromText(methodSignature + "{}", null), false);
        assertNotNull(methodBySignature);
        final RenameProcessor processor = new RenameProcessor(myProject, methodBySignature, newName, false, false);
        for (AutomaticRenamerFactory factory : Extensions.getExtensions(AutomaticRenamerFactory.EP_NAME)) {
            processor.addRenamerFactory(factory);
        }
        processor.run();
        PsiDocumentManager.getInstance(myProject).commitAllDocuments();
        FileDocumentManager.getInstance().saveAllDocuments();
    });
}
Also used : JavaPsiFacade(com.intellij.psi.JavaPsiFacade) AutomaticRenamerFactory(com.intellij.refactoring.rename.naming.AutomaticRenamerFactory) RenameProcessor(com.intellij.refactoring.rename.RenameProcessor) PsiMethod(com.intellij.psi.PsiMethod) PsiClass(com.intellij.psi.PsiClass)

Example 30 with RenameProcessor

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

the class RenameCollisionsTest method doTest.

private void doTest(final String newName) throws Exception {
    configureByFile(BASE_PATH + getTestName(false) + ".java");
    PsiElement element = TargetElementUtil.findTargetElement(myEditor, TargetElementUtil.ELEMENT_NAME_ACCEPTED | TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED);
    assertNotNull(element);
    new RenameProcessor(getProject(), element, newName, true, true).run();
    checkResultByFile(BASE_PATH + getTestName(false) + ".java.after");
}
Also used : RenameProcessor(com.intellij.refactoring.rename.RenameProcessor) PsiElement(com.intellij.psi.PsiElement)

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