Search in sources :

Example 1 with XmlMarkupDecl

use of com.intellij.psi.xml.XmlMarkupDecl in project intellij-community by JetBrains.

the class DtdResolveUtil method getNsDescriptor.

@Nullable
static XmlNSDescriptor getNsDescriptor(XmlElement element) {
    final XmlElement parentThatProvidesMetaData = PsiTreeUtil.getParentOfType(CompletionUtilCoreImpl.getOriginalElement(element), XmlDocument.class, XmlMarkupDecl.class);
    if (parentThatProvidesMetaData instanceof XmlDocument) {
        final XmlDocument document = (XmlDocument) parentThatProvidesMetaData;
        XmlNSDescriptor rootTagNSDescriptor = document.getRootTagNSDescriptor();
        if (rootTagNSDescriptor == null)
            rootTagNSDescriptor = (XmlNSDescriptor) document.getMetaData();
        return rootTagNSDescriptor;
    } else if (parentThatProvidesMetaData instanceof XmlMarkupDecl) {
        final XmlMarkupDecl markupDecl = (XmlMarkupDecl) parentThatProvidesMetaData;
        final PsiMetaData psiMetaData = markupDecl.getMetaData();
        if (psiMetaData instanceof XmlNSDescriptor) {
            return (XmlNSDescriptor) psiMetaData;
        }
    }
    return null;
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) PsiMetaData(com.intellij.psi.meta.PsiMetaData) XmlElement(com.intellij.psi.xml.XmlElement) XmlMarkupDecl(com.intellij.psi.xml.XmlMarkupDecl) XmlDocument(com.intellij.psi.xml.XmlDocument) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PsiMetaData (com.intellij.psi.meta.PsiMetaData)1 XmlDocument (com.intellij.psi.xml.XmlDocument)1 XmlElement (com.intellij.psi.xml.XmlElement)1 XmlMarkupDecl (com.intellij.psi.xml.XmlMarkupDecl)1 XmlNSDescriptor (com.intellij.xml.XmlNSDescriptor)1 Nullable (org.jetbrains.annotations.Nullable)1