Search in sources :

Example 11 with RenameProcessor

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

the class RenameClassTest method performAction.

private void performAction(String qClassName, String newName) throws Exception {
    PsiClass aClass = myJavaFacade.findClass(qClassName, GlobalSearchScope.allScope(getProject()));
    assertNotNull("Class " + qClassName + " not found", aClass);
    new RenameProcessor(myProject, aClass, newName, true, true).run();
    PsiDocumentManager.getInstance(myProject).commitAllDocuments();
    FileDocumentManager.getInstance().saveAllDocuments();
}
Also used : RenameProcessor(com.intellij.refactoring.rename.RenameProcessor) PsiClass(com.intellij.psi.PsiClass)

Example 12 with RenameProcessor

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

the class RenameMethodMultiTest method doTest.

private void doTest(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 renameProcessor = new RenameProcessor(myProject, methodBySignature, newName, false, false);
        renameProcessor.run();
        FileDocumentManager.getInstance().saveAllDocuments();
    });
}
Also used : JavaPsiFacade(com.intellij.psi.JavaPsiFacade) RenameProcessor(com.intellij.refactoring.rename.RenameProcessor) PsiMethod(com.intellij.psi.PsiMethod) PsiClass(com.intellij.psi.PsiClass)

Example 13 with RenameProcessor

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

the class SimpleNameReferenceRenameTest method doTest.

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

Example 14 with RenameProcessor

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

the class AndroidRenameTest method renameElementWithTextOccurences.

private void renameElementWithTextOccurences(final String newName) throws Throwable {
    Editor editor = myFixture.getEditor();
    PsiFile file = myFixture.getFile();
    Editor completionEditor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(editor, file);
    PsiElement element = TargetElementUtil.findTargetElement(completionEditor, TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED | TargetElementUtil.ELEMENT_NAME_ACCEPTED);
    assert element != null;
    final PsiElement substitution = RenamePsiElementProcessor.forElement(element).substituteElementToRename(element, editor);
    new RenameProcessor(myFixture.getProject(), substitution, newName, false, true).run();
}
Also used : RenameProcessor(com.intellij.refactoring.rename.RenameProcessor) Editor(com.intellij.openapi.editor.Editor)

Example 15 with RenameProcessor

use of com.intellij.refactoring.rename.RenameProcessor in project intellij by bazelbuild.

the class JavaClassRenameTest method testRenameJavaClass.

@Test
public void testRenameJavaClass() {
    PsiJavaFile javaFile = (PsiJavaFile) workspace.createPsiFile(new WorkspacePath("com/google/foo/JavaClass.java"), "package com.google.foo;", "public class JavaClass {}");
    BuildFile buildFile = createBuildFile(new WorkspacePath("com/google/foo/BUILD"), "java_library(name = \"ref2\", srcs = [\"JavaClass.java\"])");
    new RenameProcessor(getProject(), javaFile.getClasses()[0], "NewName", false, false).run();
    assertFileContents(buildFile, "java_library(name = \"ref2\", srcs = [\"NewName.java\"])");
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) RenameProcessor(com.intellij.refactoring.rename.RenameProcessor) PsiJavaFile(com.intellij.psi.PsiJavaFile) Test(org.junit.Test)

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