Java Code Examples for com.intellij.psi.xml.XmlTag#getName()

The following examples show how to use com.intellij.psi.xml.XmlTag#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViewHelperUtil.java    From idea-php-typo3-plugin with MIT License 6 votes vote down vote up
@Nullable
public static XmlElementDescriptor xmlElementDescriptorForCurrentTag(@NotNull Project project, @NotNull XmlTag tag) {
    String tagName = tag.getName();

    // Fluid ViewHelpers are always prefixed
    if (tag.getNamespacePrefix().isEmpty()) {
        return null;
    }

    boolean tagDefinedByNamespace = XmlUtil.isTagDefinedByNamespace(tag);
    if (tagDefinedByNamespace) {
        // return null;
    }

    ViewHelper viewHelperInContext = findViewHelperInContext(project, tag, tagName);
    if (viewHelperInContext == null) {
        return null;
    }

    return new ViewHelperXmlElementDescriptor(tagName, tag, viewHelperInContext);
}
 
Example 2
Source File: ISMLTagDescriptor.java    From intellij-demandware with MIT License 6 votes vote down vote up
@Override
public XmlAttributeDescriptor[] getAttributesDescriptors(@Nullable XmlTag context) {
    if (context != null) {
        final String tagName = context.getName();
        if (attrMap.containsKey(tagName)) {
            final String[] attrs = attrMap.get(tagName).split(",");
            final XmlAttributeDescriptor[] result = new XmlAttributeDescriptor[attrs.length];
            for (int i = 0; i < attrs.length; i++) {
                result[i] = new ISMLXmlAttributeDescriptor(tagName, attrs[i]);
            }
            return result;
        }
    }
    final XmlAttributeDescriptor[] commonAttributes = HtmlNSDescriptorImpl.getCommonAttributeDescriptors(context);
    return RelaxedHtmlFromSchemaElementDescriptor.addAttrDescriptorsForFacelets(context, commonAttributes);
}
 
Example 3
Source File: ISMLTagDescriptorsProvider.java    From intellij-demandware with MIT License 5 votes vote down vote up
@Nullable
@Override
public XmlElementDescriptor getDescriptor(XmlTag tag) {
    if (!(tag instanceof HtmlTag)) {
        return null;
    }

    final XmlNSDescriptor nsDescriptor = tag.getNSDescriptor(tag.getNamespace(), false);
    final XmlElementDescriptor descriptor = nsDescriptor != null ? nsDescriptor.getElementDescriptor(tag) : null;
    if (descriptor != null && !(descriptor instanceof AnyXmlElementDescriptor)) {
        return null;
    }

    return new ISMLTagDescriptor(tag.getName(), tag);
}
 
Example 4
Source File: AfxFusionElementDescriptorProvider.java    From intellij-neos with GNU General Public License v3.0 4 votes vote down vote up
/**
 * This code currently only works for fully-qualified Fusion prototypes, having exactly one ":" between namespace and name.
 *
 * NOTE: {@link ResolveEngine#getPrototypeDefinitions(Project, String, String)} only returns a single PsiElement
 *       in the list in case it found a prototype definition (i.e. a line like "prototype(X) < prototype(Y)" when
 *       searching for "X"). We trigger "jump to definition" only in this case.
 *
 *       From the {@link XmlElementDescriptor}, we cannot return more than one "Declaration", because
 *       the {@link TagNameReference}, whose resolve() method calls the descriptor's getDeclaration() method,
 *       is NOT of type {@link PsiPolyVariantReference}.
 *
 *       How is the TagNameReference created/called? The {@link com.intellij.psi.impl.source.xml.XmlTagImpl#getReferences(PsiReferenceService.Hints)} creates
 *       the TagNameReference.
 *
 * IN CASE WE WANT TO RETURN MULTIPLE RESULTS LATER, we could provide our own TagNameReference also implementing
 * PsiPolyVariantReference; by registering an own xml.xmlExtension; and overriding createTagNameReference().
 *
 * Alternatively, we could implement a custom {@link com.intellij.psi.PsiReferenceContributor}, which would be able to add
 * multiple completions. However, this would still mark the Fusion XML tag "red" and as unknown XML element in the system.
 */
@Nullable
@Override
public XmlElementDescriptor getDescriptor(XmlTag tag) {
    String key = tag.getName();
    String[] nameParts = tag.getName().split(":");

    if (nameParts.length == 2) {
        List<PsiElement> fusionPrototypes = ResolveEngine.getPrototypeDefinitions(tag.getProject(), nameParts[1], nameParts[0]);

        if (fusionPrototypes.size() == 1) {
            return new AfxXmlTagDescriptor(key, fusionPrototypes);
        }
    }

    return null;
}