From 3d027ff2a5638e465c36d71dd42a4a3f6052ff5e Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Mon, 4 Feb 2013 12:14:44 +0400 Subject: [PATCH] do not throw exceptions for invalid DOM, just log problems (e.g. http://youtrack.jetbrains.com/issue/IDEA-98943) --- .../src/com/intellij/util/xml/DomUtil.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DomUtil.java b/xml/dom-openapi/src/com/intellij/util/xml/DomUtil.java index 5803c6c26df8..9a6de097a32f 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DomUtil.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DomUtil.java @@ -221,7 +221,6 @@ public class DomUtil { } }); return result; - } ProgressManager.checkCanceled(); @@ -241,21 +240,25 @@ public class DomUtil { if (attributes) { for (final XmlAttribute attribute : tag.getAttributes()) { if (!attribute.isValid()) { - throw new AssertionError("Invalid attr: parent.valid=" + tag.isValid()); + LOG.error("Invalid attr: parent.valid=" + tag.isValid()); + continue; } GenericAttributeValue element = domManager.getDomElement(attribute); - checkHasXml(attribute, element); - ContainerUtil.addIfNotNull(element, result); + if (checkHasXml(attribute, element)) { + ContainerUtil.addIfNotNull(element, result); + } } } if (tags) { for (final XmlTag subTag : tag.getSubTags()) { if (!subTag.isValid()) { - throw new AssertionError("Invalid subtag: parent.valid=" + tag.isValid()); + LOG.error("Invalid subtag: parent.valid=" + tag.isValid()); + continue; } DomElement element = domManager.getDomElement(subTag); - checkHasXml(subTag, element); - ContainerUtil.addIfNotNull(element, result); + if (checkHasXml(subTag, element)) { + ContainerUtil.addIfNotNull(element, result); + } } } return result; @@ -263,10 +266,12 @@ public class DomUtil { return Collections.emptyList(); } - private static void checkHasXml(XmlElement psi, DomElement dom) { + private static boolean checkHasXml(XmlElement psi, DomElement dom) { if (dom != null && dom.getXmlElement() == null) { - throw new AssertionError("No xml for dom " + dom + "; attr=" + psi + ", physical=" + psi.isPhysical()); + LOG.error("No xml for dom " + dom + "; attr=" + psi + ", physical=" + psi.isPhysical()); + return false; } + return true; } public static List getDefinedChildrenOfType(@NotNull final DomElement parent, final Class type, boolean tags, boolean attributes) {