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

项目:intellij-ce-playground    文件:CheckDtdReferencesInspection.java   
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
  return new XmlElementVisitor() {
    @Override
    public void visitXmlElement(final XmlElement element) {
      if (element instanceof XmlElementContentSpec ||
          element instanceof XmlEntityRef
        ) {
        doCheckRefs(element, holder);
      }
    }
  };
}
项目:intellij-ce-playground    文件:XmlElementPattern.java   
public XmlEntityRefPattern() {
  super(new InitialPatternCondition<XmlEntityRef>(XmlEntityRef.class) {
    @Override
    public boolean accepts(@Nullable final Object o, final ProcessingContext context) {
      return o instanceof XmlEntityRef;
    }
  });
}
项目:tools-idea    文件:XmlElementPattern.java   
public XmlEntityRefPattern() {
  super(new InitialPatternCondition<XmlEntityRef>(XmlEntityRef.class) {
    public boolean accepts(@Nullable final Object o, final ProcessingContext context) {
      return o instanceof XmlEntityRef;
    }
  });
}
项目:consulo-xml    文件:XmlEntityDeclImpl.java   
@Override
public PsiElement parse(PsiFile baseFile, EntityContextType contextType, final XmlEntityRef originalElement)
{
    PsiElement dep = XmlElement.DEPENDING_ELEMENT.get(getParent());
    PsiElement dependsOnElement = getValueElement(dep instanceof PsiFile ? (PsiFile) dep : baseFile);
    String value = null;
    if(dependsOnElement instanceof XmlAttributeValue)
    {
        XmlAttributeValue attributeValue = (XmlAttributeValue) dependsOnElement;
        value = attributeValue.getValue();
    }
    else if(dependsOnElement instanceof PsiFile)
    {
        PsiFile file = (PsiFile) dependsOnElement;
        value = file.getText();
    }

    if(value == null)
    {
        return null;
    }

    DtdParsing dtdParsing = new DtdParsing(value, XML_ELEMENT_DECL, contextType, baseFile);
    PsiElement generated = dtdParsing.parse().getPsi().getFirstChild();
    if(contextType == EntityContextType.ELEMENT_CONTENT_SPEC && generated instanceof XmlElementContentSpec)
    {
        generated = generated.getFirstChild();
    }
    setDependsOnElement(generated, dependsOnElement);
    return setOriginalElement(generated, originalElement);
}
项目:consulo-xml    文件:XmlElementPattern.java   
public XmlEntityRefPattern() {
  super(new InitialPatternCondition<XmlEntityRef>(XmlEntityRef.class) {
    public boolean accepts(@Nullable final Object o, final ProcessingContext context) {
      return o instanceof XmlEntityRef;
    }
  });
}
项目:consulo-xml    文件:Psi2SaxAdapter.java   
@Override
public void visitXmlElement(XmlElement element) {
  if (element instanceof XmlEntityRef) {
    XmlUtil.processXmlElements(element, this, false, true);
  }
  super.visitXmlElement(element);
}
项目: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    文件:PhysicalDomParentStrategy.java   
@Nullable
public static PsiElement getParentTagCandidate(final XmlElement xmlElement) {
  final PsiElement parent = xmlElement.getParent();
  return parent instanceof XmlEntityRef ? parent.getParent() : parent;
}
项目:tools-idea    文件:PhysicalDomParentStrategy.java   
public static PsiElement getParentTagCandidate(final XmlElement xmlElement) {
  final PsiElement parent = xmlElement.getParent();
  return parent instanceof XmlEntityRef ? parent.getParent() : parent;
}
项目:consulo-xml    文件:PhysicalDomParentStrategy.java   
public static PsiElement getParentTagCandidate(final XmlElement xmlElement) {
  final PsiElement parent = xmlElement.getParent();
  return parent instanceof XmlEntityRef ? parent.getParent() : parent;
}
项目:consulo-xml    文件:XmlConditionalSectionImpl.java   
@Override
public boolean isIncluded(PsiFile targetFile)
{
    ASTNode child = findChildByType(XmlTokenType.XML_CONDITIONAL_SECTION_START);

    if(child != null)
    {
        child = child.getTreeNext();

        if(child != null && child.getElementType() == TokenType.WHITE_SPACE)
        {
            child = child.getTreeNext();
        }

        if(child != null)
        {
            IElementType elementType = child.getElementType();
            if(elementType == XmlTokenType.XML_CONDITIONAL_INCLUDE)
            {
                return true;
            }
            if(elementType == XmlTokenType.XML_CONDITIONAL_IGNORE)
            {
                return false;
            }

            if(elementType == XmlElementType.XML_ENTITY_REF)
            {
                XmlEntityRef xmlEntityRef = (XmlEntityRef) child.getPsi();

                final String text = xmlEntityRef.getText();
                String name = text.substring(1, text.length() - 1);

                PsiElement psiElement = targetFile != null ? XmlEntityCache.getCachedEntity(targetFile, name) : null;

                if(psiElement instanceof XmlEntityDecl)
                {
                    final XmlEntityDecl decl = (XmlEntityDecl) psiElement;

                    if(decl.isInternalReference())
                    {
                        for(ASTNode e = decl.getNode().getFirstChildNode(); e != null; e = e.getTreeNext())
                        {
                            if(e.getElementType() == XmlElementType.XML_ATTRIBUTE_VALUE)
                            {
                                final boolean b = StringUtil.stripQuotesAroundValue(e.getText()).equals("INCLUDE");
                                return b;
                            }
                        }
                    }
                }
            }
        }
    }
    return false;
}
项目: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)};
        }
    });
}