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 d536836f9387..d62d99752e75 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DomUtil.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DomUtil.java @@ -228,7 +228,9 @@ public class DomUtil { if (!attribute.isValid()) { throw new AssertionError("Invalid attr: parent.valid=" + tag.isValid()); } - ContainerUtil.addIfNotNull(domManager.getDomElement(attribute), result); + GenericAttributeValue element = domManager.getDomElement(attribute); + checkHasXml(attribute, element); + ContainerUtil.addIfNotNull(element, result); } } if (tags) { @@ -236,7 +238,9 @@ public class DomUtil { if (!subTag.isValid()) { throw new AssertionError("Invalid subtag: parent.valid=" + tag.isValid()); } - ContainerUtil.addIfNotNull(domManager.getDomElement(subTag), result); + DomElement element = domManager.getDomElement(subTag); + checkHasXml(subTag, element); + ContainerUtil.addIfNotNull(element, result); } } return result; @@ -244,6 +248,12 @@ public class DomUtil { return Collections.emptyList(); } + private static void checkHasXml(XmlElement psi, DomElement dom) { + if (dom != null && dom.getXmlElement() == null) { + throw new AssertionError("No xml for dom " + dom + "; attr=" + psi + ", physical=" + psi.isPhysical()); + } + } + public static List getDefinedChildrenOfType(@NotNull final DomElement parent, final Class type, boolean tags, boolean attributes) { return ContainerUtil.findAll(getDefinedChildren(parent, tags, attributes), type); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomElementsInspection.java b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomElementsInspection.java index d4692d5acc87..18a8a13a0eff 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomElementsInspection.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomElementsInspection.java @@ -80,7 +80,7 @@ public abstract class DomElementsInspection extends XmlSup for (final DomElement child : DomUtil.getDefinedChildren(element, true, true)) { final XmlElement element1 = child.getXmlElement(); if (element1 == null) { - LOG.error("child=" + child + "; parent=" + element); + LOG.error("child=" + child + " of class " + child.getClass() + "; parent=" + element); } if (element1.isPhysical()) { visitor.consume(child);