From ce97bd7ca6032442d5ee1b999602f2fc299a0bc9 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Fri, 23 Oct 2015 12:52:25 +0300 Subject: [PATCH] ResourceBundles: IgnoreUntranslatedLocales intention works incorrectly if default property file is missing (IDEA-146616) --- .../com/intellij/lang/properties/PropertiesUtil.java | 1 + .../incomplete/IncompletePropertyInspection.java | 6 ++---- .../IncompletePropertyInspectionOptionsPanel.java | 10 +++++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/PropertiesUtil.java b/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/PropertiesUtil.java index a56ae0faacfd..5082af159355 100644 --- a/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/PropertiesUtil.java +++ b/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/PropertiesUtil.java @@ -251,6 +251,7 @@ public class PropertiesUtil { public static String getSuffix(@NotNull PropertiesFile propertiesFile) { final String baseName = propertiesFile.getResourceBundle().getBaseName(); final String propertiesFileName = propertiesFile.getName(); + if (baseName.equals(FileUtil.getNameWithoutExtension(propertiesFileName))) return ""; return FileUtil.getNameWithoutExtension(propertiesFileName.substring(baseName.length() + 1)); } } diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/inspections/incomplete/IncompletePropertyInspection.java b/plugins/properties/src/com/intellij/lang/properties/editor/inspections/incomplete/IncompletePropertyInspection.java index e7ab1388e421..a0f1136179f7 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/inspections/incomplete/IncompletePropertyInspection.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/inspections/incomplete/IncompletePropertyInspection.java @@ -66,7 +66,7 @@ public class IncompletePropertyInspection extends ResourceBundleEditorInspection mySuffixes.clear(); final Element element = node.getChild(SUFFIXES_TAG_NAME); if (element != null) { - mySuffixes.addAll(StringUtil.split(element.getText(), ",")); + mySuffixes.addAll(StringUtil.split(element.getText(), ",", true, false)); } } @@ -185,12 +185,10 @@ public class IncompletePropertyInspection extends ResourceBundleEditorInspection } public List getPropertiesFilesWithoutTranslation(final ResourceBundle resourceBundle, final String key) { - final PropertiesFile defaultPropertiesFile = resourceBundle.getDefaultPropertiesFile(); return ContainerUtil.filter(resourceBundle.getPropertiesFiles(), new Condition() { @Override public boolean value(PropertiesFile propertiesFile) { - return !defaultPropertiesFile.equals(propertiesFile) && - propertiesFile.findPropertyByKey(key) == null && + return propertiesFile.findPropertyByKey(key) == null && !getIgnoredSuffixes().contains(PropertiesUtil.getSuffix(propertiesFile)); } }); diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/inspections/incomplete/IncompletePropertyInspectionOptionsPanel.java b/plugins/properties/src/com/intellij/lang/properties/editor/inspections/incomplete/IncompletePropertyInspectionOptionsPanel.java index 501eef6baf8a..91aedacd5a12 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/inspections/incomplete/IncompletePropertyInspectionOptionsPanel.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/inspections/incomplete/IncompletePropertyInspectionOptionsPanel.java @@ -72,9 +72,13 @@ public class IncompletePropertyInspectionOptionsPanel { protected void customizeCellRenderer(JList list, String suffix, int index, boolean selected, boolean hasFocus) { append(suffix); final Locale locale = PropertiesUtil.getLocale("_" + suffix + ".properties"); - if (locale != PropertiesUtil.DEFAULT_LOCALE && PropertiesUtil.hasDefaultLanguage(locale)) { - append(" "); - append(PropertiesUtil.getPresentableLocale(locale), SimpleTextAttributes.GRAY_ATTRIBUTES); + if (locale != PropertiesUtil.DEFAULT_LOCALE) { + if (PropertiesUtil.hasDefaultLanguage(locale)) { + append(" "); + append(PropertiesUtil.getPresentableLocale(locale), SimpleTextAttributes.GRAY_ATTRIBUTES); + } + } else { + append("Default locale"); } } });