Search in sources :

Example 86 with XmlNSDescriptor

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

the class AngularJSTagDescriptorsProvider method getDescriptor.

@Nullable
@Override
public XmlElementDescriptor getDescriptor(XmlTag xmlTag) {
    final Project project = xmlTag.getProject();
    if (!(xmlTag instanceof HtmlTag && AngularIndexUtil.hasAngularJS(project)))
        return null;
    final String tagName = xmlTag.getName();
    final String directiveName = DirectiveUtil.normalizeAttributeName(tagName);
    final XmlNSDescriptor nsDescriptor = xmlTag.getNSDescriptor(xmlTag.getNamespace(), false);
    final XmlElementDescriptor descriptor = nsDescriptor != null ? nsDescriptor.getElementDescriptor(xmlTag) : null;
    if (descriptor != null && !(descriptor instanceof AnyXmlElementDescriptor)) {
        return null;
    }
    if ((NG_CONTAINER.equals(directiveName) || NG_CONTENT.equals(directiveName) || NG_TEMPLATE.equals(directiveName)) && AngularIndexUtil.hasAngularJS2(project)) {
        return new AngularJSTagDescriptor(directiveName, createDirective(xmlTag, directiveName));
    }
    JSImplicitElement directive = DirectiveUtil.getTagDirective(directiveName, project);
    if (DirectiveUtil.isAngular2Directive(directive) && !directive.getName().equals(tagName)) {
        // we've found directive via normalized name for Angular, it should not work
        directive = null;
    }
    if (directive == null && !tagName.equals(directiveName) && AngularIndexUtil.hasAngularJS2(project)) {
        directive = DirectiveUtil.getTagDirective(tagName, project);
        if (!DirectiveUtil.isAngular2Directive(directive))
            directive = null;
    }
    return directive != null ? new AngularJSTagDescriptor(directiveName, directive) : null;
}
Also used : Project(com.intellij.openapi.project.Project) AnyXmlElementDescriptor(com.intellij.xml.impl.schema.AnyXmlElementDescriptor) XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) HtmlTag(com.intellij.psi.html.HtmlTag) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) AnyXmlElementDescriptor(com.intellij.xml.impl.schema.AnyXmlElementDescriptor) JSImplicitElement(com.intellij.lang.javascript.psi.stubs.JSImplicitElement) Nullable(org.jetbrains.annotations.Nullable)

Example 87 with XmlNSDescriptor

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

the class Struts2GlobalVariableProvider method installTaglibSupport.

private static void installTaglibSupport(@NotNull final List<FtlVariable> result, @NotNull final Module module, @NotNull @NonNls final String taglibUri, @NotNull @NonNls final String taglibPrefix) {
    final XmlFile xmlFile = JspManager.getInstance(module.getProject()).getTldFileByUri(taglibUri, module, null);
    if (xmlFile == null) {
        return;
    }
    final XmlDocument document = xmlFile.getDocument();
    if (document == null) {
        return;
    }
    final XmlNSDescriptor descriptor = (XmlNSDescriptor) document.getMetaData();
    if (descriptor == null) {
        return;
    }
    PsiElement declaration = descriptor.getDeclaration();
    if (declaration == null) {
        declaration = xmlFile;
    }
    result.add(new MyFtlLightVariable(taglibPrefix, declaration, new FtlXmlNamespaceType(descriptor)));
}
Also used : XmlFile(com.intellij.psi.xml.XmlFile) XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlDocument(com.intellij.psi.xml.XmlDocument) FtlXmlNamespaceType(com.intellij.freemarker.psi.files.FtlXmlNamespaceType)

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