use of com.intellij.refactoring.RefactoringFactory in project intellij-community by JetBrains.
the class RncRenameTest method testRenameIncludedFile.
public void testRenameIncludedFile() throws Throwable {
myTestFixture.copyFileToProject("rename-in-include-ref.rnc");
final Project project = myTestFixture.getProject();
final RefactoringFactory factory = RefactoringFactory.getInstance(project);
String fullPath = myTestFixture.getTempDirPath() + "/" + "rename-in-include-ref.rnc";
final VirtualFile copy = LocalFileSystem.getInstance().refreshAndFindFileByPath(fullPath.replace(File.separatorChar, '/'));
assert copy != null : "file " + fullPath + " not found";
final PsiFile file = PsiManager.getInstance(project).findFile(copy);
assertNotNull(file);
myTestFixture.configureByFile("rename-in-include.rnc");
final RenameRefactoring refactoring = factory.createRename(file, "rename-after.rnc");
refactoring.setPreviewUsages(false);
refactoring.setSearchInComments(false);
refactoring.setSearchInNonJavaFiles(true);
refactoring.run();
myTestFixture.checkResultByFile("rename-in-include_after.rnc");
assertEquals("rename-after.rnc", file.getName());
}
use of com.intellij.refactoring.RefactoringFactory in project intellij-community by JetBrains.
the class RenameFix method doFix.
@Override
public void doFix(Project project, ProblemDescriptor descriptor) {
if (m_targetName == null) {
super.doFix(project, descriptor);
} else {
final PsiElement nameIdentifier = descriptor.getPsiElement();
final PsiElement elementToRename = nameIdentifier.getParent();
final RefactoringFactory factory = RefactoringFactory.getInstance(project);
final RenameRefactoring renameRefactoring = factory.createRename(elementToRename, m_targetName, m_searchInStrings, m_searchInNonJavaFiles);
renameRefactoring.run();
}
}
Aggregations