ResourceBundles: IgnoreUntranslatedLocales intention works incorrectly if default property file is missing (IDEA-146616)

This commit is contained in:
Dmitry Batkovich
2015-10-23 12:52:25 +03:00
parent b813d1b7b9
commit ce97bd7ca6
3 changed files with 10 additions and 7 deletions
@@ -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));
}
}
@@ -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<PropertiesFile> getPropertiesFilesWithoutTranslation(final ResourceBundle resourceBundle, final String key) {
final PropertiesFile defaultPropertiesFile = resourceBundle.getDefaultPropertiesFile();
return ContainerUtil.filter(resourceBundle.getPropertiesFiles(), new Condition<PropertiesFile>() {
@Override
public boolean value(PropertiesFile propertiesFile) {
return !defaultPropertiesFile.equals(propertiesFile) &&
propertiesFile.findPropertyByKey(key) == null &&
return propertiesFile.findPropertyByKey(key) == null &&
!getIgnoredSuffixes().contains(PropertiesUtil.getSuffix(propertiesFile));
}
});
@@ -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");
}
}
});