Java 类com.intellij.psi.filters.XmlTagFilter 实例源码

项目:intellij-ce-playground    文件:Html5SectionsNodeProvider.java   
@NotNull
@Override
public Collection<Html5SectionTreeElement> provideNodes(@NotNull final TreeElement node) {
  if (!(node instanceof HtmlFileTreeElement)) return Collections.emptyList();

  final XmlFile xmlFile = ((HtmlFileTreeElement)node).getElement();
  final XmlDocument document = xmlFile == null ? null : xmlFile.getDocument();
  if (document == null) return Collections.emptyList();

  final List<XmlTag> rootTags = new ArrayList<XmlTag>();
  document.processElements(new FilterElementProcessor(XmlTagFilter.INSTANCE, rootTags), document);

  final Collection<Html5SectionTreeElement> result = new ArrayList<Html5SectionTreeElement>();

  for (XmlTag tag : rootTags) {
    result.addAll(Html5SectionsProcessor.processAndGetRootSections(tag));
  }

  return result;
}
项目:tools-idea    文件:Html5SectionsNodeProvider.java   
@Override
public Collection<Html5SectionTreeElement> provideNodes(final TreeElement node) {
  if (!(node instanceof HtmlFileTreeElement)) return Collections.emptyList();

  final XmlFile xmlFile = ((HtmlFileTreeElement)node).getElement();
  final XmlDocument document = xmlFile == null ? null : xmlFile.getDocument();
  if (document == null) return Collections.emptyList();

  final List<XmlTag> rootTags = new ArrayList<XmlTag>();
  document.processElements(new FilterElementProcessor(XmlTagFilter.INSTANCE, rootTags), document);

  final Collection<Html5SectionTreeElement> result = new ArrayList<Html5SectionTreeElement>();

  for (XmlTag tag : rootTags) {
    result.addAll(Html5SectionsProcessor.processAndGetRootSections(tag));
  }

  return result;
}
项目:consulo-xml    文件:Html5SectionsNodeProvider.java   
public Collection<Html5SectionTreeElement> provideNodes(final TreeElement node) {
  if (!(node instanceof HtmlFileTreeElement)) return Collections.emptyList();

  final XmlFile xmlFile = ((HtmlFileTreeElement)node).getElement();
  final XmlDocument document = xmlFile == null ? null : xmlFile.getDocument();
  if (document == null) return Collections.emptyList();

  final List<XmlTag> rootTags = new ArrayList<XmlTag>();
  document.processElements(new FilterElementProcessor(XmlTagFilter.INSTANCE, rootTags), document);

  final Collection<Html5SectionTreeElement> result = new ArrayList<Html5SectionTreeElement>();

  for (XmlTag tag : rootTags) {
    result.addAll(Html5SectionsProcessor.processAndGetRootSections(tag));
  }

  return result;
}
项目:intellij-ce-playground    文件:HtmlFileTreeElement.java   
@Override
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
  if (isHtml5SectionsMode()) {
    return Collections.emptyList(); // Html5SectionsNodeProvider will return its structure
  }

  final XmlFile xmlFile = getElement();
  final XmlDocument document = xmlFile == null ? null : xmlFile.getDocument();
  if (document == null) {
    return Collections.emptyList();
  }

  final List<XmlTag> rootTags = new SmartList<XmlTag>();
  document.processElements(new FilterElementProcessor(XmlTagFilter.INSTANCE, rootTags), document);

  if (rootTags.isEmpty()) {
    return Collections.emptyList();
  }
  else if (rootTags.size() == 1) {
    final XmlTag rootTag = rootTags.get(0);
    if ("html".equalsIgnoreCase(rootTag.getLocalName())) {
      final XmlTag[] subTags = rootTag.getSubTags();
      if (subTags.length == 1 &&
          ("head".equalsIgnoreCase(subTags[0].getLocalName()) || "body".equalsIgnoreCase(subTags[0].getLocalName()))) {
        return new HtmlTagTreeElement(subTags[0]).getChildrenBase();
      }
      return new HtmlTagTreeElement(rootTag).getChildrenBase();
    }

    return Collections.<StructureViewTreeElement>singletonList(new HtmlTagTreeElement(rootTag));
  }
  else {
    final Collection<StructureViewTreeElement> result = new ArrayList<StructureViewTreeElement>(rootTags.size());
    for (XmlTag tag : rootTags) {
      result.add(new HtmlTagTreeElement(tag));
    }
    return result;
  }
}
项目:tools-idea    文件:HtmlFileTreeElement.java   
@Override
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
  if (isHtml5SectionsMode()) {
    return Collections.emptyList(); // Html5SectionsNodeProvider will return its structure
  }

  final XmlFile xmlFile = getElement();
  final XmlDocument document = xmlFile == null ? null : xmlFile.getDocument();
  if (document == null) {
    return Collections.emptyList();
  }

  final List<XmlTag> rootTags = new SmartList<XmlTag>();
  document.processElements(new FilterElementProcessor(XmlTagFilter.INSTANCE, rootTags), document);

  if (rootTags.isEmpty()) {
    return Collections.emptyList();
  }
  else if (rootTags.size() == 1) {
    final XmlTag rootTag = rootTags.get(0);
    if ("html".equalsIgnoreCase(rootTag.getLocalName())) {
      final XmlTag[] subTags = rootTag.getSubTags();
      if (subTags.length == 1 &&
          ("head".equalsIgnoreCase(subTags[0].getLocalName()) || "body".equalsIgnoreCase(subTags[0].getLocalName()))) {
        return new HtmlTagTreeElement(subTags[0]).getChildrenBase();
      }
      return new HtmlTagTreeElement(rootTag).getChildrenBase();
    }

    return Collections.<StructureViewTreeElement>singletonList(new HtmlTagTreeElement(rootTag));
  }
  else {
    final Collection<StructureViewTreeElement> result = new ArrayList<StructureViewTreeElement>(rootTags.size());
    for (XmlTag tag : rootTags) {
      result.add(new HtmlTagTreeElement(tag));
    }
    return result;
  }
}
项目: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    文件:HtmlFileTreeElement.java   
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
  if (isHtml5SectionsMode()) {
    return Collections.emptyList(); // Html5SectionsNodeProvider will return its structure
  }

  final XmlFile xmlFile = getElement();
  final XmlDocument document = xmlFile == null ? null : xmlFile.getDocument();
  if (document == null) return Collections.emptyList();

  final List<XmlTag> rootTags = new ArrayList<XmlTag>();
  document.processElements(new FilterElementProcessor(XmlTagFilter.INSTANCE, rootTags), document);

  if (rootTags.isEmpty()) return Collections.emptyList();

  if (rootTags.size() == 1) {
    final XmlTag rootTag = rootTags.get(0);

    if ("html".equalsIgnoreCase(rootTag.getLocalName())) {
      final XmlTag[] subTags = rootTag.getSubTags();
      if (subTags.length == 1 &&
          ("head".equalsIgnoreCase(subTags[0].getLocalName()) || "body".equalsIgnoreCase(subTags[0].getLocalName()))) {
        return new HtmlTagTreeElement(subTags[0]).getChildrenBase();
      }

      return new HtmlTagTreeElement(rootTag).getChildrenBase();
    }

    return Arrays.<StructureViewTreeElement>asList(new HtmlTagTreeElement(rootTag));
  }
  else {
    final Collection<StructureViewTreeElement> result = new ArrayList<StructureViewTreeElement>();

    for (XmlTag tag : rootTags) {
      result.add(new HtmlTagTreeElement(tag));
    }

    return result;
  }
}
项目: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)};
        }
    });
}