Search in sources :

Example 81 with XmlNSDescriptor

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

the class XmlElementDescriptorByType method getNSDescriptor.

@Override
public XmlNSDescriptor getNSDescriptor() {
    XmlNSDescriptor nsDescriptor = NSDescriptor;
    if (nsDescriptor == null) {
        final XmlFile file = XmlUtil.getContainingFile(getType(null).getDeclaration());
        if (file == null)
            return null;
        final XmlDocument document = file.getDocument();
        if (document == null)
            return null;
        NSDescriptor = nsDescriptor = (XmlNSDescriptor) document.getMetaData();
    }
    return nsDescriptor;
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlFile(com.intellij.psi.xml.XmlFile) XmlDocument(com.intellij.psi.xml.XmlDocument)

Example 82 with XmlNSDescriptor

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

the class XmlNSDescriptorImpl method getNSDescriptorToSearchIn.

@NotNull
static XmlNSDescriptorImpl getNSDescriptorToSearchIn(XmlTag rootTag, final String name, XmlNSDescriptorImpl defaultNSDescriptor) {
    if (name == null)
        return defaultNSDescriptor;
    final String namespacePrefix = XmlUtil.findPrefixByQualifiedName(name);
    if (namespacePrefix.length() > 0) {
        final String namespace = rootTag.getNamespaceByPrefix(namespacePrefix);
        final XmlNSDescriptor nsDescriptor = rootTag.getNSDescriptor(namespace, true);
        if (nsDescriptor instanceof XmlNSDescriptorImpl) {
            return (XmlNSDescriptorImpl) nsDescriptor;
        }
    }
    return defaultNSDescriptor;
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) NotNull(org.jetbrains.annotations.NotNull)

Example 83 with XmlNSDescriptor

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

the class XmlNSDescriptorImpl method findNSDescriptor.

private XmlNSDescriptorImpl findNSDescriptor(final XmlTag tag, final XmlDocument document) {
    final XmlNSDescriptorImpl nsDescriptor;
    if (IMPORT_TAG_NAME.equals(tag.getLocalName())) {
        final XmlNSDescriptor importedDescriptor = (XmlNSDescriptor) document.getMetaData();
        nsDescriptor = (importedDescriptor instanceof XmlNSDescriptorImpl) ? (XmlNSDescriptorImpl) importedDescriptor : this;
    } else {
        nsDescriptor = this;
    }
    return nsDescriptor;
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor)

Example 84 with XmlNSDescriptor

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

the class XmlMover method moveTags.

private static boolean moveTags(MoveInfo info, XmlTag moved, XmlTag target, boolean down) {
    if (target.getParent() == moved) {
        // we are going to jump into our own children
        // this can mean that target computed incorrectly
        XmlTag next = down ? PsiTreeUtil.getNextSiblingOfType(moved, XmlTag.class) : PsiTreeUtil.getPrevSiblingOfType(moved, XmlTag.class);
        if (next == null)
            return info.prohibitMove();
        info.toMove = new LineRange(moved);
        info.toMove2 = new LineRange(next);
        return true;
    } else if (moved.getParent() == target) {
        return false;
    }
    LineRange targetRange = new LineRange(target);
    targetRange = XmlChildRole.CLOSING_TAG_START_FINDER.findChild(target.getNode()) == null ? new LineRange(targetRange.startLine, targetRange.endLine - 1) : targetRange;
    if (targetRange.contains(info.toMove2)) {
        // we are going to jump into sibling tag
        XmlElementDescriptor descriptor = moved.getDescriptor();
        if (descriptor == null)
            return false;
        XmlNSDescriptor nsDescriptor = descriptor.getNSDescriptor();
        if (nsDescriptor == null)
            return false;
        XmlFile descriptorFile = nsDescriptor.getDescriptorFile();
        if (descriptorFile == null || XmlDocumentImpl.isAutoGeneratedSchema(descriptorFile))
            return false;
        if (!TagNameVariantCollector.couldContain(target, moved)) {
            info.toMove = new LineRange(moved);
            info.toMove2 = targetRange;
            return true;
        }
    }
    return false;
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor)

Example 85 with XmlNSDescriptor

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

the class HtmlElementDescriptorImpl method getAttributeDescriptor.

@Override
public XmlAttributeDescriptor getAttributeDescriptor(String attributeName, final XmlTag context) {
    String caseSensitiveAttributeName = !myCaseSensitive ? attributeName.toLowerCase() : attributeName;
    XmlAttributeDescriptor descriptor = super.getAttributeDescriptor(caseSensitiveAttributeName, context);
    if (descriptor == null)
        descriptor = RelaxedHtmlFromSchemaElementDescriptor.getAttributeDescriptorFromFacelets(attributeName, context);
    if (descriptor == null) {
        String prefix = XmlUtil.findPrefixByQualifiedName(attributeName);
        if ("xml".equals(prefix)) {
            // todo this is not technically correct dtd document references namespaces but we should handle it at least for xml stuff
            XmlNSDescriptor nsdescriptor = context.getNSDescriptor(XmlUtil.XML_NAMESPACE_URI, true);
            if (nsdescriptor instanceof XmlNSDescriptorImpl) {
                descriptor = ((XmlNSDescriptorImpl) nsdescriptor).getAttribute(XmlUtil.findLocalNameByQualifiedName(caseSensitiveAttributeName), XmlUtil.XML_NAMESPACE_URI, context);
            }
        }
    }
    if (descriptor == null && HtmlUtil.isHtml5Context(context)) {
        descriptor = myDelegate.getAttributeDescriptor(attributeName, context);
    }
    return descriptor;
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlAttributeDescriptor(com.intellij.xml.XmlAttributeDescriptor) XmlNSDescriptorImpl(com.intellij.xml.impl.schema.XmlNSDescriptorImpl)

Aggregations

XmlNSDescriptor (com.intellij.xml.XmlNSDescriptor)87 XmlElementDescriptor (com.intellij.xml.XmlElementDescriptor)60 XmlTag (com.intellij.psi.xml.XmlTag)52 XmlAttributeDescriptor (com.intellij.xml.XmlAttributeDescriptor)32 XmlFile (com.intellij.psi.xml.XmlFile)21 Nullable (org.jetbrains.annotations.Nullable)11 XmlDocument (com.intellij.psi.xml.XmlDocument)10 PsiElement (com.intellij.psi.PsiElement)5 XmlAttribute (com.intellij.psi.xml.XmlAttribute)5 AnyXmlElementDescriptor (com.intellij.xml.impl.schema.AnyXmlElementDescriptor)5 XmlNSDescriptorImpl (com.intellij.xml.impl.schema.XmlNSDescriptorImpl)5 CachedValue (com.intellij.psi.util.CachedValue)3 NotNull (org.jetbrains.annotations.NotNull)3 FlexMxmlNSDescriptor (com.intellij.javascript.flex.mxml.schema.FlexMxmlNSDescriptor)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 PsiFile (com.intellij.psi.PsiFile)2 HtmlTag (com.intellij.psi.html.HtmlTag)2 PsiMetaData (com.intellij.psi.meta.PsiMetaData)2 PsiElementProcessor (com.intellij.psi.search.PsiElementProcessor)2 XmlElementDescriptorImpl (com.intellij.xml.impl.schema.XmlElementDescriptorImpl)2