Java 类com.intellij.psi.xml.XmlElementDecl 实例源码

项目:consulo-xml    文件:XmlNSDescriptorImpl.java   
@Override
public void validate(@NotNull XmlDocument document, @NotNull ValidationHost host)
{
    if(document.getLanguage() == DTDLanguage.INSTANCE)
    {
        final List<XmlElementDecl> decls = new ArrayList<>(3);

        XmlUtil.processXmlElements(document, new PsiElementProcessor()
        {
            @Override
            public boolean execute(@NotNull final PsiElement element)
            {
                if(element instanceof XmlElementDecl)
                {
                    decls.add((XmlElementDecl) element);
                }
                return true;
            }
        }, false);
        XmlUtil.doDuplicationCheckForElements(decls.toArray(new XmlElementDecl[decls.size()]), new HashMap<>(decls.size()), XML_ELEMENT_DECL_PROVIDER, host);
        return;
    }
    ExternalDocumentValidator.doValidation(document, host);
}
项目:intellij-ce-playground    文件:XmlElementRenameValidator.java   
@Override
public ElementPattern<? extends PsiElement> getPattern() {
  return or(
    XmlPatterns.xmlTag().withMetaData(
      or(StandardPatterns.instanceOf(XmlElementDescriptor.class),
         StandardPatterns.instanceOf(XmlAttributeDescriptor.class))
    ),
    psiElement(XmlElementDecl.class),
    psiElement(XmlAttributeDecl.class),
    XmlPatterns.xmlTag().withDescriptor(
      or(StandardPatterns.instanceOf(XmlElementDescriptor.class),
         StandardPatterns.instanceOf(XmlAttributeDescriptor.class))
    )
  );
}
项目:tools-idea    文件:XmlElementRenameValidator.java   
@Override
public ElementPattern<? extends PsiElement> getPattern() {
  return or(
    XmlPatterns.xmlTag().withMetaData(
      or(PlatformPatterns.instanceOf(XmlElementDescriptor.class),
         PlatformPatterns.instanceOf(XmlAttributeDescriptor.class))
    ),
    psiElement(XmlElementDecl.class),
    psiElement(XmlAttributeDecl.class),
    XmlPatterns.xmlTag().withDescriptor(
      or(PlatformPatterns.instanceOf(XmlElementDescriptor.class),
         PlatformPatterns.instanceOf(XmlAttributeDescriptor.class))
    )
  );
}
项目:consulo-xml    文件:XmlNSDescriptorImpl.java   
private CachedValue<Map<String, XmlElementDescriptor>> doBuildDeclarationMap()
{
    return CachedValuesManager.getManager(myElement.getProject()).createCachedValue(() ->
    {
        final List<XmlElementDecl> result = new ArrayList<>();
        myElement.processElements(new FilterElementProcessor(new ClassFilter(XmlElementDecl.class), result), getDeclaration());
        final Map<String, XmlElementDescriptor> ret = new LinkedHashMap<>((int) (result.size() * 1.5));
        Set<PsiFile> dependencies = new THashSet<>(1);
        dependencies.add(myDescriptorFile);

        for(final XmlElementDecl xmlElementDecl : result)
        {
            final String name = xmlElementDecl.getName();
            if(name != null)
            {
                if(!ret.containsKey(name))
                {
                    ret.put(name, new XmlElementDescriptorImpl(xmlElementDecl));
                    // if element descriptor was produced from entity reference use proper dependency
                    PsiElement dependingElement = xmlElementDecl.getUserData(XmlElement.DEPENDING_ELEMENT);
                    if(dependingElement != null)
                    {
                        PsiFile dependingElementContainingFile = dependingElement.getContainingFile();
                        if(dependingElementContainingFile != null)
                        {
                            dependencies.add(dependingElementContainingFile);
                        }
                    }
                }
            }
        }
        return new CachedValueProvider.Result<>(ret, dependencies.toArray());
    }, false);
}
项目:consulo-xml    文件:XmlApplicationComponent.java   
@Override
public void contributeMetaData(final MetaDataRegistrar registrar)
{
    {
        registrar.registerMetaData(new AndFilter(new NamespaceFilter(XmlUtil.SCHEMA_URIS), new ClassFilter(XmlDocument.class)), SchemaNSDescriptor.class);

        registrar.registerMetaData(new AndFilter(XmlTagFilter.INSTANCE, new NamespaceFilter(XmlUtil.SCHEMA_URIS), new XmlTextFilter("schema")), SchemaNSDescriptor.class);
    }
    {
        registrar.registerMetaData(new OrFilter(new AndFilter(new ContentFilter(new OrFilter(new ClassFilter(XmlElementDecl.class), new ClassFilter(XmlEntityDecl.class), new ClassFilter
                (XmlConditionalSection.class), new ClassFilter(XmlEntityRef.class))), new ClassFilter(XmlDocument.class)), new ClassFilter(XmlMarkupDecl.class)), XmlNSDescriptorImpl.class);
    }

    {
        registrar.registerMetaData(new AndFilter(XmlTagFilter.INSTANCE, new NamespaceFilter(XmlUtil.SCHEMA_URIS), new XmlTextFilter("element")), XmlElementDescriptorImpl.class);
    }

    {
        registrar.registerMetaData(new AndFilter(XmlTagFilter.INSTANCE, new NamespaceFilter(XmlUtil.SCHEMA_URIS), new XmlTextFilter("attribute")), XmlAttributeDescriptorImpl.class);
    }

    {
        registrar.registerMetaData(new ClassFilter(XmlElementDecl.class), com.intellij.xml.impl.dtd.XmlElementDescriptorImpl.class);
    }

    {
        registrar.registerMetaData(new ClassFilter(XmlAttributeDecl.class), com.intellij.xml.impl.dtd.XmlAttributeDescriptorImpl.class);
    }

    {
        registrar.registerMetaData(new AndFilter(new ClassFilter(XmlDocument.class), new TargetNamespaceFilter(XmlUtil.XHTML_URI), new NamespaceFilter(XmlUtil.SCHEMA_URIS)),
                RelaxedHtmlFromSchemaNSDescriptor.class);
    }

    {
        registrar.registerMetaData(new AndFilter(XmlTagFilter.INSTANCE, new NamespaceFilter(XmlUtil.SCHEMA_URIS), new XmlTextFilter("complexType", "simpleType", "group", "attributeGroup")),
                NamedObjectDescriptor.class);
    }
}
项目:consulo-xml    文件:XmlElementRenameValidator.java   
@Override
public ElementPattern<? extends PsiElement> getPattern() {
  return or(
    XmlPatterns.xmlTag().withMetaData(
      or(PlatformPatterns.instanceOf(XmlElementDescriptor.class),
         PlatformPatterns.instanceOf(XmlAttributeDescriptor.class))
    ),
    psiElement(XmlElementDecl.class),
    psiElement(XmlAttributeDecl.class),
    XmlPatterns.xmlTag().withDescriptor(
      or(PlatformPatterns.instanceOf(XmlElementDescriptor.class),
         PlatformPatterns.instanceOf(XmlAttributeDescriptor.class))
    )
  );
}
项目:consulo-xml    文件:XmlFindUsagesProvider.java   
@Override
@NotNull
public String getType(@NotNull PsiElement element)
{
    if(element instanceof XmlTag)
    {
        final PsiMetaData metaData = ((XmlTag) element).getMetaData();
        if(metaData != null && metaData.getDeclaration() instanceof XmlTag)
        {
            return ((XmlTag) metaData.getDeclaration()).getName();
        }
        return LangBundle.message("xml.terms.xml.tag");
    }
    if(element instanceof XmlElementDecl)
    {
        return LangBundle.message("xml.terms.tag");
    }
    else if(element instanceof XmlAttributeDecl)
    {
        return LangBundle.message("xml.terms.attribute");
    }
    else if(element instanceof XmlAttributeValue)
    {
        return LangBundle.message("xml.terms.attribute.value");
    }
    else if(element instanceof XmlEntityDecl)
    {
        return LangBundle.message("xml.terms.entity");
    }
    else if(element instanceof XmlAttribute)
    {
        return LangBundle.message("xml.terms.attribute");
    }
    else if(element instanceof XmlComment)
    {
        return LangBundle.message("xml.terms.variable");
    }
    throw new IllegalArgumentException("Cannot get type for " + element);
}
项目:intellij-ce-playground    文件:DtdSelectioner.java   
@Override
public boolean canSelect(PsiElement e) {
  return e instanceof XmlAttlistDecl || e instanceof XmlElementDecl;
}
项目:tools-idea    文件:DtdSelectioner.java   
public boolean canSelect(PsiElement e) {
  return e instanceof XmlAttlistDecl || e instanceof XmlElementDecl;
}
项目:consulo-xml    文件:XmlNSDescriptorImpl.java   
@Override
public String getName(@NotNull final XmlElementDecl psiElement)
{
    return psiElement.getName();
}
项目:consulo-xml    文件:XmlNSDescriptorImpl.java   
@Override
@NotNull
public String getNameKey(@NotNull final XmlElementDecl psiElement, @NotNull final String name)
{
    return name;
}
项目:consulo-xml    文件:XmlNSDescriptorImpl.java   
@Override
@NotNull
public PsiElement getNodeForMessage(@NotNull final XmlElementDecl psiElement)
{
    return psiElement.getNameElement();
}
项目:consulo-xml    文件:DtdSelectioner.java   
public boolean canSelect(PsiElement e) {
  return e instanceof XmlAttlistDecl || e instanceof XmlElementDecl;
}
项目:consulo-xml    文件:XmlReferenceContributor.java   
@Override
public void registerReferenceProviders(@NotNull final PsiReferenceRegistrar registrar)
{

    final IdReferenceProvider idReferenceProvider = new IdReferenceProvider();

    XmlUtil.registerXmlAttributeValueReferenceProvider(registrar, idReferenceProvider.getIdForAttributeNames(), idReferenceProvider.getIdForFilter(), true, idReferenceProvider,
            PsiReferenceRegistrar.DEFAULT_PRIORITY);

    final DtdReferencesProvider dtdReferencesProvider = new DtdReferencesProvider();
    //registerReferenceProvider(null, XmlEntityDecl.class,dtdReferencesProvider);
    registrar.registerReferenceProvider(PlatformPatterns.psiElement(XmlEntityRef.class), dtdReferencesProvider);
    registrar.registerReferenceProvider(PlatformPatterns.psiElement(XmlDoctype.class), dtdReferencesProvider);
    registrar.registerReferenceProvider(PlatformPatterns.psiElement(XmlElementDecl.class), dtdReferencesProvider);
    registrar.registerReferenceProvider(PlatformPatterns.psiElement(XmlAttlistDecl.class), dtdReferencesProvider);
    registrar.registerReferenceProvider(PlatformPatterns.psiElement(XmlElementContentSpec.class), dtdReferencesProvider);
    registrar.registerReferenceProvider(PlatformPatterns.psiElement(XmlToken.class), dtdReferencesProvider);
    registrar.registerReferenceProvider(xmlAttributeValue(), new ArbitraryPlaceUrlReferenceProvider(), PsiReferenceRegistrar.LOWER_PRIORITY);


    URIReferenceProvider uriProvider = new URIReferenceProvider();
    XmlUtil.registerXmlAttributeValueReferenceProvider(registrar, null, dtdReferencesProvider.getSystemReferenceFilter(), uriProvider);

    XmlUtil.registerXmlAttributeValueReferenceProvider(registrar, new String[]{"href"}, new ScopeFilter(new ParentElementFilter(new AndFilter(new AndFilter(XmlTagFilter.INSTANCE, new
            XmlTextFilter("include")), new NamespaceFilter(XmlUtil.XINCLUDE_URI)), 2)), true, new XmlBaseReferenceProvider(true));

    registrar.registerReferenceProvider(xmlAttributeValue().withLocalName("base").withNamespace(XmlUtil.XML_NAMESPACE_URI), new XmlBaseReferenceProvider(false));

    XmlUtil.registerXmlAttributeValueReferenceProvider(registrar, new String[]{MicrodataUtil.ITEM_TYPE}, null, new MicrodataReferenceProvider());

    final SchemaReferencesProvider schemaReferencesProvider = new SchemaReferencesProvider();

    XmlUtil.registerXmlAttributeValueReferenceProvider(registrar, schemaReferencesProvider.getCandidateAttributeNamesForSchemaReferences(), new ScopeFilter(new ParentElementFilter(new
            NamespaceFilter(XmlUtil.SCHEMA_URIS), 2)), schemaReferencesProvider);

    registrar.registerReferenceProvider(xmlAttributeValue(xmlAttribute().withNamespace(XmlUtil.XML_SCHEMA_INSTANCE_URI)).
            withLocalName("type"), schemaReferencesProvider);

    registrar.registerReferenceProvider(xmlAttributeValue(xmlAttribute().withNamespace(XmlUtil.XML_SCHEMA_INSTANCE_URI)).
            withLocalName("noNamespaceSchemaLocation", "schemaLocation"), uriProvider);

    registrar.registerReferenceProvider(xmlAttributeValue().withLocalName("schemaLocation", "namespace").
            withSuperParent(2, xmlTag().withNamespace(XmlUtil.SCHEMA_URIS).withLocalName("import", "include", "redefine")), uriProvider);

    XmlUtil.registerXmlAttributeValueReferenceProvider(registrar, null, URIReferenceProvider.ELEMENT_FILTER, true, uriProvider);

    XmlUtil.registerXmlAttributeValueReferenceProvider(registrar, new String[]{"encoding"}, new ScopeFilter(new ParentElementFilter(new ClassFilter(XmlProcessingInstruction.class))), true, new
            XmlEncodingReferenceProvider());

    registrar.registerReferenceProvider(xmlAttributeValue(), new XmlPrefixReferenceProvider());
    registrar.registerReferenceProvider(xmlAttributeValue(), new XmlEnumeratedValueReferenceProvider(), PsiReferenceRegistrar.LOWER_PRIORITY);
    registrar.registerReferenceProvider(xmlTag(), XmlEnumeratedValueReferenceProvider.forTags(), PsiReferenceRegistrar.LOWER_PRIORITY);

    registrar.registerReferenceProvider(xmlAttributeValue().withLocalName("source").withSuperParent(2, xmlTag().withLocalName("documentation").withNamespace(XmlUtil.SCHEMA_URIS)), new
            PsiReferenceProvider()
    {
        @NotNull
        @Override
        public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context)
        {
            return new PsiReference[]{new WebReference(element)};
        }
    });
}
项目:consulo-xml    文件:XmlFindUsagesProvider.java   
@Override
public boolean canFindUsagesFor(@NotNull PsiElement element)
{
    return element instanceof XmlElementDecl || element instanceof XmlAttributeDecl || element instanceof XmlEntityDecl || element instanceof XmlTag || element instanceof XmlAttributeValue ||
            element instanceof PsiFile || element instanceof XmlComment;
}