use of com.intellij.refactoring.rename.RenameHandler in project intellij-community by JetBrains.
the class JavaFXRenameTest method doTestPropertyRenameHandler.
public void doTestPropertyRenameHandler(String... files) throws Exception {
myFixture.configureByFiles(files);
final MapDataContext dataContext = new MapDataContext();
dataContext.put(CommonDataKeys.EDITOR, getEditor());
final RenameHandler renameHandler = RenameHandlerRegistry.getInstance().getRenameHandler(dataContext);
assertTrue(renameHandler instanceof JavaFxPropertyRenameHandler);
}
use of com.intellij.refactoring.rename.RenameHandler in project intellij-community by JetBrains.
the class MavenDomTestCase method assertCannotRename.
protected void assertCannotRename() throws Exception {
MapDataContext context = createRenameDataContext(myProjectPom, "new name");
RenameHandler handler = RenameHandlerRegistry.getInstance().getRenameHandler(context);
if (handler == null)
return;
try {
invokeRename(context, handler);
} catch (CommonRefactoringUtil.RefactoringErrorHintException e) {
if (!e.getMessage().startsWith("Cannot perform refactoring.")) {
throw e;
}
}
}
use of com.intellij.refactoring.rename.RenameHandler in project android by JetBrains.
the class RenameTest method sourceRoot.
@Test
public void sourceRoot() throws Exception {
guiTest.importSimpleApplication();
final Project project = guiTest.ideFrame().getProject();
Module[] modules = ModuleManager.getInstance(project).getModules();
for (Module module : modules) {
final VirtualFile[] sourceRoots = ModuleRootManager.getInstance(module).getSourceRoots();
for (final VirtualFile sourceRoot : sourceRoots) {
PsiDirectory directory = GuiQuery.getNonNull(() -> PsiManager.getInstance(project).findDirectory(sourceRoot));
for (final RenameHandler handler : Extensions.getExtensions(RenameHandler.EP_NAME)) {
if (handler instanceof DirectoryAsPackageRenameHandler) {
final RenameDialogFixture renameDialog = RenameDialogFixture.startFor(directory, handler, guiTest.robot());
assertFalse(renameDialog.warningExists(null));
renameDialog.setNewName(renameDialog.getNewName() + 1);
// 'Rename dialog' show a warning asynchronously to the text change, that's why we wait here for the
// warning to appear
Wait.seconds(1).expecting("error text to appear").until(() -> renameDialog.warningExists(AndroidBundle.message("android.refactoring.gradle.warning.rename.source.root")));
renameDialog.clickCancel();
return;
}
}
}
}
}
use of com.intellij.refactoring.rename.RenameHandler in project intellij-community by JetBrains.
the class RenameModuleTest method testRename.
public void testRename() throws Exception {
String moduleName = "module";
String newModuleName = "moduleA";
Module module = createModule(moduleName);
assertEquals(moduleName, module.getName());
MapDataContext context = new MapDataContext();
context.put(LangDataKeys.MODULE_CONTEXT, module);
final RenameHandler renameHandler = RenameHandlerRegistry.getInstance().getRenameHandler(context);
assertNotNull(renameHandler);
Messages.setTestInputDialog(new TestInputDialog() {
@Override
public String show(String message) {
return null;
}
@Override
public String show(String message, @Nullable InputValidator validator) {
assertNotNull(validator);
boolean canClose = validator.canClose(newModuleName);
assertTrue(canClose);
return newModuleName;
}
});
renameHandler.invoke(myProject, PsiElement.EMPTY_ARRAY, context);
assertEquals(newModuleName, module.getName());
}
use of com.intellij.refactoring.rename.RenameHandler in project intellij-community by JetBrains.
the class JarRootsRefreshTest method rename.
private static void rename(PsiNamedElement file, String newName) {
DataContext psiDataContext = SimpleDataContext.getSimpleContext(CommonDataKeys.PSI_ELEMENT.getName(), file);
RenameHandler renameHandler = RenameHandlerRegistry.getInstance().getRenameHandler(psiDataContext);
assertNotNull(renameHandler);
PsiElementRenameHandler.rename(file, file.getProject(), file, null, newName);
}
Aggregations