diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomImplUtil.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomImplUtil.java index e637508681d8..eaeac3929e8e 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomImplUtil.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomImplUtil.java @@ -34,6 +34,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.lang.reflect.*; +import java.util.Collections; import java.util.List; import java.util.Set; @@ -146,7 +147,12 @@ public class DomImplUtil { if (!tag.isValid()) { throw new AssertionError("Invalid tag"); } - return ContainerUtil.findAll(tag.getSubTags(), new Condition() { + final XmlTag[] tags = tag.getSubTags(); + if (tags.length == 0) { + return Collections.emptyList(); + } + + return ContainerUtil.findAll(tags, new Condition() { public boolean value(XmlTag childTag) { try { return isNameSuitable(name, childTag.getLocalName(), childTag.getName(), childTag.getNamespace(), file); @@ -166,6 +172,10 @@ public class DomImplUtil { } public static List findSubTags(final XmlTag[] tags, final EvaluatedXmlName name, final XmlFile file) { + if (tags.length == 0) { + return Collections.emptyList(); + } + return ContainerUtil.findAll(tags, new Condition() { public boolean value(XmlTag childTag) { return isNameSuitable(name, childTag, file); @@ -248,12 +258,22 @@ public class DomImplUtil { } public static List getCustomSubTags(final DomInvocationHandler handler, final XmlTag[] subTags, final XmlFile file) { + if (subTags.length == 0) { + return Collections.emptyList(); + } + final DomGenericInfoEx info = handler.getGenericInfo(); final Set usedNames = new THashSet(); - for (final DomCollectionChildDescription description : info.getCollectionChildrenDescriptions()) { + List collectionChildrenDescriptions = info.getCollectionChildrenDescriptions(); + //noinspection ForLoopReplaceableByForEach + for (int i = 0, size = collectionChildrenDescriptions.size(); i < size; i++) { + DomCollectionChildDescription description = collectionChildrenDescriptions.get(i); usedNames.add(description.getXmlName()); } - for (final DomFixedChildDescription description : info.getFixedChildrenDescriptions()) { + List fixedChildrenDescriptions = info.getFixedChildrenDescriptions(); + //noinspection ForLoopReplaceableByForEach + for (int i = 0, size = fixedChildrenDescriptions.size(); i < size; i++) { + DomFixedChildDescription description = fixedChildrenDescriptions.get(i); usedNames.add(description.getXmlName()); } return ContainerUtil.findAll(subTags, new Condition() {