From 7a6a9573a060d96b5fbc600ec1f381a70cab227e Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Tue, 4 Mar 2014 18:29:28 +0400 Subject: [PATCH] fix entities resolve without root tag --- .../psi/impl/source/xml/XmlEntityRefImpl.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityRefImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityRefImpl.java index e666cdcea090..8bd39976fe44 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityRefImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityRefImpl.java @@ -152,27 +152,28 @@ public class XmlEntityRefImpl extends XmlElementImpl implements XmlEntityRef { ) { XmlDocument document = ((XmlFile)targetElement).getDocument(); final XmlTag rootTag = document.getRootTag(); + XmlFile descriptorFile = null; - if (rootTag != null && document.getUserData(DISABLE_ENTITY_EXPAND) == null) { + if (HtmlUtil.isHtml5Document(document)) { + descriptorFile = XmlUtil.findXmlFile((XmlFile)targetElement, Html5SchemaProvider.getCharsDtdLocation()); + } else if (rootTag != null && document.getUserData(DISABLE_ENTITY_EXPAND) == null) { final XmlElementDescriptor descriptor = rootTag.getDescriptor(); if (descriptor != null && !(descriptor instanceof AnyXmlElementDescriptor)) { - PsiElement element = !HtmlUtil.isHtml5Context(rootTag) ? descriptor.getDeclaration() : - XmlUtil.findXmlFile((XmlFile)targetElement, Html5SchemaProvider.getCharsDtdLocation()); + PsiElement element = descriptor.getDeclaration(); final PsiFile containingFile = element != null ? element.getContainingFile():null; - final XmlFile descriptorFile = containingFile instanceof XmlFile ? (XmlFile)containingFile:null; - - if (descriptorFile != null && - !descriptorFile.getName().equals(((XmlFile)targetElement).getName()+".dtd")) { - deps.add(descriptorFile); - XmlUtil.processXmlElements( - descriptorFile, - processor, - true - ); - } + descriptorFile = containingFile instanceof XmlFile ? (XmlFile)containingFile:null; } } + if (descriptorFile != null && + !descriptorFile.getName().equals(((XmlFile)targetElement).getName() + ".dtd")) { + deps.add(descriptorFile); + XmlUtil.processXmlElements( + descriptorFile, + processor, + true + ); + } } return new CachedValueProvider.Result(result[0], ArrayUtil.toObjectArray(deps));