use of com.intellij.refactoring.rename.RenameDialog in project intellij-community by JetBrains.
the class PyMagicLiteralRenameHandler method invoke.
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
PsiElement element = getElement(file, editor);
if (element == null) {
return;
}
RenameDialog.showRenameDialog(dataContext, new RenameDialog(project, element, null, editor));
}
use of com.intellij.refactoring.rename.RenameDialog in project android by JetBrains.
the class AndroidRenameHandler method performApplicationPackageRenaming.
private static void performApplicationPackageRenaming(@NotNull Project project, @NotNull Editor editor, @NotNull DataContext context) {
PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(context);
if (!(element instanceof XmlAttributeValue)) {
return;
}
final Module module = ModuleUtilCore.findModuleForPsiElement(element);
if (module == null) {
return;
}
RenameDialog.showRenameDialog(context, new RenameDialog(project, element, null, editor) {
@NotNull
@Override
protected String getLabelText() {
return "Rename Android application package of module '" + module.getName() + "' to:";
}
@Override
protected void canRun() throws ConfigurationException {
final String name = getNewName();
if (name.length() == 0) {
throw new ConfigurationException(AndroidBundle.message("specify.package.name.error"));
}
if (!AndroidUtils.isValidAndroidPackageName(name)) {
throw new ConfigurationException(AndroidBundle.message("not.valid.package.name.error", name));
}
if (!AndroidCommonUtils.contains2Identifiers(name)) {
throw new ConfigurationException(AndroidBundle.message("package.name.must.contain.2.ids.error"));
}
super.canRun();
}
});
}
use of com.intellij.refactoring.rename.RenameDialog in project android by JetBrains.
the class AndroidRenameHandler method performValueResourceRenaming.
private static void performValueResourceRenaming(Project project, Editor editor, DataContext dataContext, XmlTag tag) {
final XmlAttribute nameAttribute = tag.getAttribute("name");
if (nameAttribute == null) {
return;
}
final XmlAttributeValue attributeValue = nameAttribute.getValueElement();
if (attributeValue == null) {
return;
}
RenameDialog.showRenameDialog(dataContext, new RenameDialog(project, new ValueResourceElementWrapper(attributeValue), null, editor));
}
use of com.intellij.refactoring.rename.RenameDialog in project intellij by bazelbuild.
the class RenameRefactoringTest method testRenameSuggestionForBuildFile.
@Test
public void testRenameSuggestionForBuildFile() {
BuildFile buildFile = createBuildFile(new WorkspacePath("java/com/google/BUILD"));
RenamePsiElementProcessor processor = RenamePsiElementProcessor.forElement(buildFile);
RenameDialog dialog = processor.createRenameDialog(getProject(), buildFile, buildFile, null);
String[] suggestions = dialog.getSuggestedNames();
assertThat(suggestions[0]).isEqualTo("BUILD");
}
use of com.intellij.refactoring.rename.RenameDialog in project android by JetBrains.
the class ThemeEditorComponent method renameTheme.
/**
* Uses Android Studio refactoring to rename the current theme
*/
private void renameTheme() {
ConfiguredThemeEditorStyle selectedTheme = getSelectedTheme();
assert selectedTheme != null;
assert selectedTheme.isProjectStyle();
PsiElement namePsiElement = selectedTheme.getNamePsiElement();
if (namePsiElement == null) {
return;
}
RenameDialog renameDialog = new RenameDialog(myThemeEditorContext.getProject(), namePsiElement, null, null);
renameDialog.show();
if (renameDialog.isOK()) {
String newName = renameDialog.getNewName();
// We don't need to call reload here, because myResourceChangeListener will take care of it
myThemeName = selectedTheme.getQualifiedName().replace(selectedTheme.getName(), newName);
mySubStyleName = null;
}
}
Aggregations