IDEA-96656 IntelliLang allows duplicate injection definitions in IntelliLang.xml

This commit is contained in:
Gregory.Shrago
2012-12-05 18:47:17 +04:00
parent b0db55c84f
commit 2c98eae0f0
@@ -271,14 +271,16 @@ public class Configuration implements PersistentStateComponent<Element>, Modific
if (enumeration == null || !enumeration.hasMoreElements()) {
LOG.warn(descriptor.getPluginId() +": " + configBean.getConfigUrl() + " was not found");
}
while (enumeration.hasMoreElements()) {
URL url = enumeration.nextElement();
if (!visited.add(url.getFile())) continue; // for DEBUG mode
try {
cfgList.add(load(url.openStream()));
}
catch (Exception e) {
LOG.warn(e);
else {
while (enumeration.hasMoreElements()) {
URL url = enumeration.nextElement();
if (!visited.add(url.getFile())) continue; // for DEBUG mode
try {
cfgList.add(load(url.openStream()));
}
catch (Exception e) {
LOG.warn(e);
}
}
}
}
@@ -302,16 +304,17 @@ public class Configuration implements PersistentStateComponent<Element>, Modific
}
protected Element getState(final Element element) {
final List<String> injectorIds = new ArrayList<String>(myInjections.keySet());
Comparator<BaseInjection> comparator = new Comparator<BaseInjection>() {
public int compare(final BaseInjection o1, final BaseInjection o2) {
return Comparing.compare(o1.getDisplayName(), o2.getDisplayName());
}
};
List<String> injectorIds = new ArrayList<String>(myInjections.keySet());
Collections.sort(injectorIds);
for (String key : injectorIds) {
final List<BaseInjection> injections = new ArrayList<BaseInjection>(myInjections.get(key));
TreeSet<BaseInjection> injections = new TreeSet<BaseInjection>(comparator);
injections.addAll(myInjections.get(key));
injections.removeAll(getDefaultInjections());
Collections.sort(injections, new Comparator<BaseInjection>() {
public int compare(final BaseInjection o1, final BaseInjection o2) {
return Comparing.compare(o1.getDisplayName(), o2.getDisplayName());
}
});
for (BaseInjection injection : injections) {
element.addContent(injection.getState());
}
@@ -357,6 +360,7 @@ public class Configuration implements PersistentStateComponent<Element>, Modific
}
else {
elements.add(rootElement);
//noinspection unchecked
elements.addAll(rootElement.getChildren("component"));
state = ContainerUtil.find(elements, new Condition<Element>() {
public boolean value(final Element element) {