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

The following examples show how to use com.intellij.psi.xml.XmlTag#getNamespace() . 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: GlobalConfigsToolWindowPanel.java    From mule-intellij-plugins with Apache License 2.0 6 votes vote down vote up
private boolean isDevKitConfig(XmlTag tag, XmlFile baseFile) {
    Module module = ModuleUtilCore.findModuleForPsiElement(baseFile);

    String namespace = tag.getNamespace();
    List<XmlSchemaProvider> providers = XmlSchemaProvider.getAvailableProviders(baseFile);

    for (XmlSchemaProvider provider : providers) {
        Set<String> locations = provider.getLocations(namespace, baseFile);
        for (String location : locations) {
            XmlFile schema = provider.getSchema(location, module, baseFile);
            if (schema != null) {
                String schemaFile = schema.getText();
                if (schemaFile.contains("http://www.mulesoft.org/schema/mule/devkit")) {
                    return true;
                }
            }
        }
    }

    return false;
}
 
Example 2
Source File: MuleElementInsertHandler.java    From mule-intellij-plugins with Apache License 2.0 5 votes vote down vote up
protected boolean isNamespaceBound(PsiElement psiElement) {
    PsiElement parent = psiElement.getParent();
    if (!(parent instanceof XmlTag)) return false;
    final XmlTag tag = (XmlTag) parent;
    final XmlElementDescriptor tagDescriptor = tag.getDescriptor();
    final String tagNamespace = tag.getNamespace();
    return tagDescriptor != null && !(tagDescriptor instanceof AnyXmlElementDescriptor) && namespace.equals(tagNamespace);
}
 
Example 3
Source File: XmlCamelIdeaUtils.java    From camel-idea-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public boolean skipEndpointValidation(PsiElement element) {
    // only accept xml tags from namespaces we support
    XmlTag xml = PsiTreeUtil.getParentOfType(element, XmlTag.class);
    if (xml != null) {
        String ns = xml.getNamespace();
        // accept empty namespace which can be from testing
        boolean accepted = StringUtils.isEmpty(ns) || isAcceptedNamespace(ns);
        LOG.trace("XmlTag " + xml.getName() + " with namespace: " + ns + " is accepted namespace: " + accepted);
        return !accepted; // skip is the opposite
    }

    return false;
}
 
Example 4
Source File: MuleConfigUtils.java    From mule-intellij-plugins with Apache License 2.0 4 votes vote down vote up
public static QName getQName(XmlTag xmlTag) {
    return new QName(xmlTag.getNamespace(), xmlTag.getLocalName());
}