diff --git a/platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableExtensionPointUtil.java b/platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableExtensionPointUtil.java index 0c3737630752..66a3ec7544ee 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableExtensionPointUtil.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableExtensionPointUtil.java @@ -24,7 +24,10 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.util.ArrayUtilRt; +import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; +import gnu.trove.THashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -262,7 +265,7 @@ public class ConfigurableExtensionPointUtil { * @return the map of different groups of settings */ public static Map> groupConfigurables(@NotNull List configurables) { - Map> tree = ContainerUtil.newHashMap(); + Map> tree = new THashMap<>(); for (Configurable configurable : configurables) { if (!(configurable instanceof ConfigurableWrapper)) { Node.add(tree, "other", configurable); @@ -270,30 +273,39 @@ public class ConfigurableExtensionPointUtil { } ConfigurableWrapper wrapper = (ConfigurableWrapper)configurable; - String id = wrapper.getId(); + String id; + try { + id = wrapper.getId(); + } + catch (Throwable e) { + LOG.error("Cannot create configurable", e); + continue; + } + Node node = Node.get(tree, id); if (node.myValue != null) { LOG.warn("ignore configurable with duplicated id: " + id); + continue; } - else { - String parentId = wrapper.getParentId(); - String groupId = wrapper.getExtensionPoint().groupId; - if (groupId != null) { - if (parentId != null) { - LOG.warn("ignore deprecated groupId: " + groupId + " for id: " + id); - } - else { - //TODO:LOG.warn("use deprecated groupId: " + groupId + " for id: " + id); - parentId = groupId; - } + + String parentId = wrapper.getParentId(); + String groupId = wrapper.getExtensionPoint().groupId; + if (groupId != null) { + if (parentId != null) { + LOG.warn("ignore deprecated groupId: " + groupId + " for id: " + id); + } + else { + //TODO:LOG.warn("use deprecated groupId: " + groupId + " for id: " + id); + parentId = groupId; } - parentId = Node.cyclic(tree, parentId, "other", id, node); - node.myParent = Node.add(tree, parentId, node); - node.myValue = wrapper; } + parentId = Node.cyclic(tree, parentId, "other", id, node); + node.myParent = Node.add(tree, parentId, node); + node.myValue = wrapper; } - Map> map = ContainerUtil.newHashMap(); - for (String id : tree.keySet().toArray(new String[tree.size()])) { + + Map> map = new THashMap<>(); + for (String id : ArrayUtilRt.toStringArray(tree.keySet())) { Node node = tree.get(id); if (node != null) { List list = getConfigurables(tree, node); @@ -548,7 +560,7 @@ public class ConfigurableExtensionPointUtil { Node myParent; V myValue; - private static Node get(Map> tree, I id) { + private static Node get(@NotNull Map> tree, @NotNull I id) { Node node = tree.get(id); if (node == null) { node = new Node<>(); @@ -557,16 +569,16 @@ public class ConfigurableExtensionPointUtil { return node; } - private static Node add(Map> tree, I id, Object child) { + private static Node add(@NotNull Map> tree, @NotNull I id, Object child) { Node node = get(tree, id); if (node.myChildren == null) { - node.myChildren = ContainerUtil.newArrayList(); + node.myChildren = new SmartList<>(); } node.myChildren.add(child); return node; } - private static boolean cyclic(Map> tree, I id, Node parent) { + private static boolean cyclic(@NotNull Map> tree, @NotNull I id, Node parent) { for (Node node = tree.get(id); node != null; node = node.myParent) { if (node == parent) { return true; @@ -575,7 +587,7 @@ public class ConfigurableExtensionPointUtil { return false; } - private static I cyclic(Map> tree, I id, I idDefault, I idNode, Node parent) { + private static I cyclic(@NotNull Map> tree, @Nullable I id, I idDefault, I idNode, Node parent) { if (id == null) { id = idDefault; }