com.intellij.refactoring.rename.RenameProcessor Java Examples
The following examples show how to use
com.intellij.refactoring.rename.RenameProcessor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RenameImportedProtoTest.java From protobuf-jetbrains-plugin with Apache License 2.0 | 6 votes |
public void testRenameImportedProtoAtCaretPosition() { PsiFile[] files = myFixture.configureByFiles( "rename/import/source.proto", "rename/import/import.proto" ); PsiElement elementAtCaret = myFixture.getElementAtCaret(); Project project = myFixture.getProject(); RenameProcessor processor = new RenameProcessor(project, elementAtCaret, "renamed.proto", false, false); for (AutomaticRenamerFactory factory : Extensions.getExtensions(AutomaticRenamerFactory.EP_NAME)) { processor.addRenamerFactory(factory); } processor.run(); Assert.assertEquals("renamed.proto", files[1].getName()); Assert.assertEquals("import \"rename/import/renamed.proto\";", ((ProtoPsiFileRoot) files[0]).getProtoRoot().getImports().get(0).getText()); }
Example #2
Source File: JavaClassRenameTest.java From intellij with Apache License 2.0 | 6 votes |
@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\"])"); }
Example #3
Source File: MemberInplaceRenamer.java From consulo with Apache License 2.0 | 6 votes |
protected void performRenameInner(PsiElement element, String newName) { final RenamePsiElementProcessor elementProcessor = RenamePsiElementProcessor.forElement(element); final RenameProcessor renameProcessor = new RenameProcessor(myProject, element, newName, elementProcessor.isToSearchInComments(element), elementProcessor.isToSearchForTextOccurrences(element)){ @Override public void doRun() { try { super.doRun(); } finally { restoreCaretOffsetAfterRename(); } } }; for (AutomaticRenamerFactory factory : Extensions.getExtensions(AutomaticRenamerFactory.EP_NAME)) { if (factory.getOptionName() != null && factory.isApplicable(element)) { renameProcessor.addRenamerFactory(factory); } } renameProcessor.run(); }
Example #4
Source File: BashFileReferenceTest.java From BashSupport with Apache License 2.0 | 5 votes |
private void doRename(PsiFile psiElement, String newName) { final RenameProcessor processor = new RenameProcessor(myProject, psiElement, newName, false, false); for (AutomaticRenamerFactory factory : Extensions.getExtensions(AutomaticRenamerFactory.EP_NAME)) { processor.addRenamerFactory(factory); } processor.run(); PsiDocumentManager.getInstance(myProject).commitAllDocuments(); FileDocumentManager.getInstance().saveAllDocuments(); }
Example #5
Source File: LombokLoggerHandler.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void processLoggerField(@NotNull PsiField psiField, @NotNull PsiClass psiClass, @NotNull AbstractLogProcessor logProcessor, @NotNull String lombokLoggerName) { if (!lombokLoggerName.equals(psiField.getName())) { RenameProcessor processor = new RenameProcessor(psiField.getProject(), psiField, lombokLoggerName, false, false); processor.doRun(); } addAnnotation(psiClass, logProcessor.getSupportedAnnotationClasses()[0]); psiField.delete(); }
Example #6
Source File: RenameElementFix.java From consulo with Apache License 2.0 | 5 votes |
@Override public void invoke(@Nonnull final Project project, @Nonnull final PsiFile file, @Nullable Editor editor, @Nonnull final PsiElement startElement, @Nonnull PsiElement endElement) { if (isAvailable(project, null, file)) { LOG.assertTrue(file == startElement.getContainingFile()); if (!FileModificationService.getInstance().prepareFileForWrite(file)) return; RenameProcessor processor = new RenameProcessor(project, startElement, myNewName, false, false); processor.run(); } }
Example #7
Source File: RenameRefactoringImpl.java From consulo with Apache License 2.0 | 5 votes |
public RenameRefactoringImpl(Project project, PsiElement element, String newName, boolean toSearchInComments, boolean toSearchInNonJavaFiles) { super(new RenameProcessor(project, element, newName, toSearchInComments, toSearchInNonJavaFiles)); }
Example #8
Source File: AutomaticRenamer.java From consulo with Apache License 2.0 | 5 votes |
@RequiredReadAction public void findUsages(List<UsageInfo> result, final boolean searchInStringsAndComments, final boolean searchInNonJavaFiles, List<UnresolvableCollisionUsageInfo> unresolvedUsages, Map<PsiElement, String> allRenames) { for (Iterator<PsiNamedElement> iterator = myElements.iterator(); iterator.hasNext();) { final PsiNamedElement variable = iterator.next(); RenameProcessor.assertNonCompileElement(variable); final boolean success = findUsagesForElement(variable, result, searchInStringsAndComments, searchInNonJavaFiles, unresolvedUsages, allRenames); if (!success) { iterator.remove(); } } }
Example #9
Source File: RenameChangeInfo.java From consulo with Apache License 2.0 | 5 votes |
public void perform() { final PsiNameIdentifierOwner element = getNamedElement(); if (element != null) { final String name = element.getName(); ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { element.setName(myOldName); } }); new RenameProcessor(element.getProject(), element, name, false, false).run(); } }
Example #10
Source File: RenameChangeInfo.java From consulo with Apache License 2.0 | 5 votes |
public void perform() { final PsiNameIdentifierOwner element = getNamedElement(); if (element != null) { final String name = element.getName(); ApplicationManager.getApplication().runWriteAction(() -> { element.setName(myOldName); }); new RenameProcessor(element.getProject(), element, name, false, false).run(); } }
Example #11
Source File: CodeInsightTestFixtureImpl.java From consulo with Apache License 2.0 | 4 votes |
@Override public void renameElement(final PsiElement element, final String newName, final boolean searchInComments, final boolean searchTextOccurrences) { final PsiElement substitution = RenamePsiElementProcessor.forElement(element).substituteElementToRename(element, myEditor); if (substitution == null) return; new RenameProcessor(getProject(), substitution, newName, searchInComments, searchTextOccurrences).run(); }