Java 类com.intellij.psi.filters.position.NamespaceFilter 实例源码

项目:intellij-ce-playground    文件:ApplicationLoader.java   
private static void registerMetaData() {
  final MetaDataRegistrar registrar = MetaDataRegistrar.getInstance();
  registrar.registerMetaData(
          new AndFilter(
                  new NamespaceFilter(RNG_NAMESPACE),
                  new ClassFilter(XmlDocument.class)
          ),
          RngNsDescriptor.class);

  registrar.registerMetaData(
          new ClassFilter(RncDocument.class),
          RngNsDescriptor.class);

  registrar.registerMetaData(new ElementFilter() {
    @Override
    public boolean isAcceptable(Object element, PsiElement context) {
      if (element instanceof XmlTag) {
        final XmlTag tag = (XmlTag)element;
        final DomElement domElement = DomManager.getDomManager(tag.getProject()).getDomElement(tag);
        return domElement instanceof RngDefine;
      }
      return false;
    }

    @Override
    public boolean isClassAcceptable(Class hintClass) {
      return XmlTag.class.isAssignableFrom(hintClass);
    }
  }, RngDefineMetaData.class);
}
项目:tools-idea    文件:ApplicationLoader.java   
private static void registerMetaData() {
  final MetaDataRegistrar registrar = MetaDataRegistrar.getInstance();
  registrar.registerMetaData(
          new AndFilter(
                  new NamespaceFilter(RNG_NAMESPACE),
                  new ClassFilter(XmlDocument.class)
          ),
          RngNsDescriptor.class);

  registrar.registerMetaData(
          new ClassFilter(RncDocument.class),
          RngNsDescriptor.class);

  registrar.registerMetaData(new ElementFilter() {
    public boolean isAcceptable(Object element, PsiElement context) {
      if (element instanceof XmlTag) {
        final XmlTag tag = (XmlTag)element;
        final DomElement domElement = DomManager.getDomManager(tag.getProject()).getDomElement(tag);
        return domElement instanceof RngDefine;
      }
      return false;
    }

    public boolean isClassAcceptable(Class hintClass) {
      return XmlTag.class.isAssignableFrom(hintClass);
    }
  }, RngDefineMetaData.class);
}
项目:consulo-xml    文件:ApplicationLoader.java   
private static void registerMetaData()
{
    final MetaDataRegistrar registrar = MetaDataRegistrar.getInstance();
    registrar.registerMetaData(new AndFilter(new NamespaceFilter(RNG_NAMESPACE), new ClassFilter(XmlDocument.class)), RngNsDescriptor.class);

    registrar.registerMetaData(new ClassFilter(RncDocument.class), RngNsDescriptor.class);

    registrar.registerMetaData(new ElementFilter()
    {
        @Override
        public boolean isAcceptable(Object element, PsiElement context)
        {
            if(element instanceof XmlTag)
            {
                final XmlTag tag = (XmlTag) element;
                final DomElement domElement = DomManager.getDomManager(tag.getProject()).getDomElement(tag);
                return domElement instanceof RngDefine;
            }
            return false;
        }

        @Override
        public boolean isClassAcceptable(Class hintClass)
        {
            return XmlTag.class.isAssignableFrom(hintClass);
        }
    }, RngDefineMetaData.class);
}
项目: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);
    }
}
项目:intellij-ce-playground    文件: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);
  }
}
项目:intellij-ce-playground    文件:JavaFXMetaDataContributor.java   
@Override
public void contributeMetaData(MetaDataRegistrar registrar) {
  MetaDataRegistrar.getInstance().registerMetaData(new RootTagFilter(new NamespaceFilter(JavaFXNamespaceProvider.JAVAFX_NAMESPACE)), JavaFXNSDescriptor.class);
}
项目:tools-idea    文件:XmlApplicationComponent.java   
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);
  }
}
项目:tools-idea    文件:XmlReferenceContributor.java   
public void registerReferenceProviders(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);

    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, uriProvider);

    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());
  }
项目:tools-idea    文件:JavaFXMetaDataContributor.java   
@Override
public void contributeMetaData(MetaDataRegistrar registrar) {
  MetaDataRegistrar.getInstance().registerMetaData(new RootTagFilter(new NamespaceFilter(JavaFXNamespaceProvider.JAVAFX_NAMESPACE)), JavaFXNSDescriptor.class);
}
项目:ibatis-plugin    文件:IbatisReferenceProvider.java   
public IbatisReferenceProvider() {
    ibatisSqlMapConfigNamespaceFilter = new NamespaceFilter(IbatisConstants.CONFIGURATION_DTDS);
    ibatisSqlMapNamespaceFilter = new NamespaceFilter(IbatisConstants.SQLMAP_DTDS);
    ibatisAbatorNamespaceFilter = new NamespaceFilter(IbatisConstants.ABATOR_DTDS);
}
项目:consulo-javafx    文件:JavaFXMetaDataContributor.java   
@Override
public void contributeMetaData(MetaDataRegistrar registrar) {
  MetaDataRegistrar.getInstance().registerMetaData(new RootTagFilter(new NamespaceFilter(JavaFXNamespaceProvider.JAVAFX_NAMESPACE)), JavaFXNSDescriptor.class);
}
项目: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)};
        }
    });
}
项目:ibatis-plugin    文件:IbatisReferenceProvider.java   
/**
 * Register the given provider on the given XmlAttribute/Namespace/XmlTag(s) combination.
 *
 * @param provider        Provider to install.
 * @param attributeNames  Attribute names.
 * @param namespaceFilter Namespace for tag(s).
 * @param tagName         tag name
 */
private void registerXmlAttributeValueReferenceProvider(final NamespaceFilter namespaceFilter, String tagName, final @NonNls String[] attributeNames, final PsiReferenceProvider provider) {
    XmlUtil.registerXmlAttributeValueReferenceProvider(registrary, attributeNames, andTagNames(namespaceFilter, tagName), provider);
}