mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
rename properties files when bundle exist; rename property key from resource bundle editor (IDEA-11842 )
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
|
||||
<lang.parserDefinition language="Properties" implementationClass="com.intellij.lang.properties.parsing.PropertiesParserDefinition"/>
|
||||
<renameHandler implementation="com.intellij.lang.properties.ResourceBundleRenameHandler"/>
|
||||
<renameHandler implementation="com.intellij.lang.properties.ResourceBundleKeyRenameHandler"/>
|
||||
<renameHandler implementation="com.intellij.lang.properties.PropertyRenameHandler"/>
|
||||
<stubElementTypeHolder class="com.intellij.lang.properties.parsing.PropertiesElementTypes"/>
|
||||
<renamePsiElementProcessor implementation="com.intellij.refactoring.rename.RenamePropertyProcessor"/>
|
||||
|
||||
+4
-1
@@ -20,6 +20,7 @@
|
||||
package com.intellij.lang.properties;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.lang.properties.editor.ResourceBundleAsVirtualFile;
|
||||
import com.intellij.lang.properties.editor.ResourceBundleEditor;
|
||||
import com.intellij.lang.properties.psi.PropertiesFile;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
@@ -53,9 +54,11 @@ public class ResourceBundleRenameHandler implements RenameHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
final VirtualFile virtualFile = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
|
||||
|
||||
ResourceBundleEditor editor = ResourceBundleUtil.getEditor(dataContext);
|
||||
return (editor == null || editor.getState(FileEditorStateLevel.NAVIGATION).getPropertyName() == null /* user selected non-bundle key element */)
|
||||
&& bundle.getPropertiesFiles(project).size() > 1;
|
||||
&& bundle.getPropertiesFiles(project).size() > 1 && (virtualFile instanceof ResourceBundleAsVirtualFile || virtualFile == null);
|
||||
}
|
||||
|
||||
public boolean isRenaming(DataContext dataContext) {
|
||||
|
||||
@@ -54,6 +54,8 @@ public class ResourceBundleUtil {
|
||||
public static ResourceBundle getResourceBundleFromDataContext(@NotNull DataContext dataContext) {
|
||||
PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataContext);
|
||||
if (element instanceof IProperty) return null; //rename property
|
||||
final ResourceBundle[] bundles = ResourceBundle.ARRAY_DATA_KEY.getData(dataContext);
|
||||
if (bundles != null && bundles.length == 1) return bundles[0];
|
||||
VirtualFile virtualFile = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
|
||||
if (virtualFile == null) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user