Search in sources :

Example 1 with XmlName

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

the class MavenPluginConfigurationParameterDomExtender method registerExtensions.

@Override
public void registerExtensions(@NotNull MavenDomConfigurationParameter param, @NotNull DomExtensionsRegistrar r) {
    for (XmlAttribute each : param.getXmlTag().getAttributes()) {
        String name = each.getName();
        if (CompletionUtil.DUMMY_IDENTIFIER_TRIMMED.equals(name))
            continue;
        r.registerGenericAttributeValueChildExtension(new XmlName(name), String.class);
    }
}
Also used : XmlAttribute(com.intellij.psi.xml.XmlAttribute) XmlName(com.intellij.util.xml.XmlName)

Example 2 with XmlName

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

the class CustomAntElementsRegistry method getCompletionVariants.

@NotNull
public Set<XmlName> getCompletionVariants(AntDomElement parentElement) {
    if (parentElement instanceof AntDomCustomElement) {
        // this case is already handled in AntDomExtender when defining children
        return Collections.emptySet();
    }
    final Set<XmlName> result = new HashSet<>();
    final Pair<AntDomMacroDef, AntDomScriptDef> contextMacroOrScriptDef = getContextMacroOrScriptDef(parentElement);
    final AntDomMacroDef restrictToMacroDef = contextMacroOrScriptDef != null ? contextMacroOrScriptDef.getFirst() : null;
    final AntDomScriptDef restrictToScriptDef = contextMacroOrScriptDef != null ? contextMacroOrScriptDef.getSecond() : null;
    final boolean parentIsDataType = parentElement.isDataType();
    for (final XmlName xmlName : myCustomElements.keySet()) {
        final AntDomNamedElement declaringElement = myDeclarations.get(xmlName);
        if (declaringElement instanceof AntDomMacrodefElement) {
            if (restrictToMacroDef == null || !restrictToMacroDef.equals(declaringElement.getParentOfType(AntDomMacroDef.class, true))) {
                continue;
            }
        } else if (declaringElement instanceof AntDomScriptdefElement) {
            if (restrictToScriptDef == null || !restrictToScriptDef.equals(declaringElement.getParentOfType(AntDomScriptDef.class, true))) {
                continue;
            }
        }
        if (declaringElement != null) {
            if (declaringElement.equals(restrictToMacroDef) || declaringElement.equals(restrictToScriptDef)) {
                continue;
            }
        }
        if (parentIsDataType) {
            if (declaringElement instanceof AntDomMacroDef || declaringElement instanceof AntDomScriptDef || declaringElement instanceof AntDomTaskdef) {
                continue;
            }
            if (declaringElement instanceof AntDomTypeDef) {
                final AntDomTypeDef typedef = (AntDomTypeDef) declaringElement;
                final Class clazz = lookupClass(xmlName);
                if (clazz != null && typedef.isTask(clazz)) {
                    continue;
                }
            }
        }
        result.add(xmlName);
    }
    return result;
}
Also used : XmlName(com.intellij.util.xml.XmlName) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with XmlName

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

the class CustomAntElementsRegistry method addCustomDefinition.

private void addCustomDefinition(@NotNull AntDomNamedElement declaringTag, String customTagName, String nsUri, ClassProvider classProvider) {
    final XmlName xmlName = new XmlName(customTagName, nsUri == null ? "" : nsUri);
    myCustomElements.put(xmlName, classProvider);
    myDeclarations.put(xmlName, declaringTag);
}
Also used : XmlName(com.intellij.util.xml.XmlName)

Example 4 with XmlName

use of com.intellij.util.xml.XmlName in project android by JetBrains.

the class AttributeProcessingUtil method processMenuItemAttributes.

private static void processMenuItemAttributes(@NotNull AndroidFacet facet, @NotNull DomElement element, @NotNull Collection<XmlName> skippedAttributes, @NotNull AttributeProcessor callback) {
    ResourceManager manager = facet.getSystemResourceManager();
    if (manager == null) {
        return;
    }
    AttributeDefinitions styleables = manager.getAttributeDefinitions();
    if (styleables == null) {
        return;
    }
    StyleableDefinition styleable = styleables.getStyleableByName("MenuItem");
    if (styleable == null) {
        getLog().warn("No StyleableDefinition for MenuItem");
        return;
    }
    for (AttributeDefinition attribute : styleable.getAttributes()) {
        String name = attribute.getName();
        // .lint.checks.AppCompatResourceDetector.
        if (name.equals(ATTR_SHOW_AS_ACTION)) {
            AndroidModuleModel model = AndroidModuleModel.get(facet);
            if (model != null && GradleUtil.dependsOn(model, APPCOMPAT_LIB_ARTIFACT)) {
                if (skippedAttributes.add(new XmlName(name, AUTO_URI))) {
                    registerAttribute(attribute, "MenuItem", AUTO_URI, element, callback);
                }
                continue;
            }
        }
        if (skippedAttributes.add(new XmlName(name, ANDROID_URI))) {
            registerAttribute(attribute, "MenuItem", ANDROID_URI, element, callback);
        }
    }
}
Also used : AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) XmlName(com.intellij.util.xml.XmlName) ResourceManager(org.jetbrains.android.resourceManagers.ResourceManager) SystemResourceManager(org.jetbrains.android.resourceManagers.SystemResourceManager)

Example 5 with XmlName

use of com.intellij.util.xml.XmlName in project android by JetBrains.

the class AttributeProcessingUtil method registerExistingAttributes.

@NotNull
private static Set<XmlName> registerExistingAttributes(@NotNull AndroidFacet facet, @NotNull XmlTag tag, @NotNull AndroidDomElement element, @NotNull AttributeProcessor callback) {
    final Set<XmlName> result = new HashSet<>();
    XmlAttribute[] attrs = tag.getAttributes();
    for (XmlAttribute attr : attrs) {
        String localName = attr.getLocalName();
        if (!localName.endsWith(CompletionUtil.DUMMY_IDENTIFIER_TRIMMED)) {
            if (!"xmlns".equals(attr.getNamespacePrefix())) {
                AttributeDefinition attrDef = AndroidDomUtil.getAttributeDefinition(facet, attr);
                if (attrDef != null) {
                    String namespace = attr.getNamespace();
                    result.add(new XmlName(attr.getLocalName(), attr.getNamespace()));
                    registerAttribute(attrDef, null, namespace.length() > 0 ? namespace : null, element, callback);
                }
            }
        }
    }
    return result;
}
Also used : XmlAttribute(com.intellij.psi.xml.XmlAttribute) XmlName(com.intellij.util.xml.XmlName) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

XmlName (com.intellij.util.xml.XmlName)15 EvaluatedXmlName (com.intellij.util.xml.EvaluatedXmlName)3 DomExtension (com.intellij.util.xml.reflect.DomExtension)3 XmlAttribute (com.intellij.psi.xml.XmlAttribute)2 XmlFile (com.intellij.psi.xml.XmlFile)2 XmlTag (com.intellij.psi.xml.XmlTag)2 EvaluatedXmlNameImpl (com.intellij.util.xml.EvaluatedXmlNameImpl)2 ResolvingConverter (com.intellij.util.xml.ResolvingConverter)2 CustomDomChildrenDescription (com.intellij.util.xml.reflect.CustomDomChildrenDescription)2 ManifestElement (org.jetbrains.android.dom.manifest.ManifestElement)2 SystemResourceManager (org.jetbrains.android.resourceManagers.SystemResourceManager)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)1 NullableComputable (com.intellij.openapi.util.NullableComputable)1 RecursionGuard (com.intellij.openapi.util.RecursionGuard)1 PsiClass (com.intellij.psi.PsiClass)1 PsiElement (com.intellij.psi.PsiElement)1 XmlElementType (com.intellij.psi.xml.XmlElementType)1 Converter (com.intellij.util.xml.Converter)1