Java 类com.intellij.psi.impl.source.xml.XmlEntityRefImpl 实例源码

项目:intellij-ce-playground    文件:XmlUtil.java   
public static String generateDocumentDTD(XmlDocument doc, boolean full) {
  final Map<String, List<String>> tags = new LinkedHashMap<String, List<String>>();
  final Map<String, List<MyAttributeInfo>> attributes = new LinkedHashMap<String, List<MyAttributeInfo>>();

  try {
    XmlEntityRefImpl.setNoEntityExpandOutOfDocument(doc, true);
    final XmlTag rootTag = doc.getRootTag();
    computeTag(rootTag, tags, attributes, full);

    // For supporting not well-formed XML
    for (PsiElement element = rootTag != null ? rootTag.getNextSibling() : null; element != null; element = element.getNextSibling()) {
      if (element instanceof XmlTag) {
        computeTag((XmlTag)element, tags, attributes, full);
      }
    }
  }
  finally {
    XmlEntityRefImpl.setNoEntityExpandOutOfDocument(doc, false);
  }

  final StringBuilder buffer = new StringBuilder();
  for (final String tagName : tags.keySet()) {
    buffer.append(generateElementDTD(tagName, tags.get(tagName), attributes.get(tagName)));
  }
  return buffer.toString();
}
项目:tools-idea    文件:XmlUtil.java   
public static String generateDocumentDTD(XmlDocument doc, boolean full) {
  final Map<String, List<String>> tags = new LinkedHashMap<String, List<String>>();
  final Map<String, List<MyAttributeInfo>> attributes = new LinkedHashMap<String, List<MyAttributeInfo>>();

  try {
    XmlEntityRefImpl.setNoEntityExpandOutOfDocument(doc, true);
    final XmlTag rootTag = doc.getRootTag();
    computeTag(rootTag, tags, attributes, full);

    // For supporting not well-formed XML
    for (PsiElement element = rootTag != null ? rootTag.getNextSibling() : null; element != null; element = element.getNextSibling()) {
      if (element instanceof XmlTag) {
        computeTag((XmlTag)element, tags, attributes, full);
      }
    }
  }
  finally {
    XmlEntityRefImpl.setNoEntityExpandOutOfDocument(doc, false);
  }

  final StringBuilder buffer = new StringBuilder();
  for (final String tagName : tags.keySet()) {
    buffer.append(generateElementDTD(tagName, tags.get(tagName), attributes.get(tagName)));
  }
  return buffer.toString();
}
项目:consulo-xml    文件:XmlPsiUtil.java   
private static PsiElement parseEntityDecl(final XmlEntityDecl entityDecl, final PsiFile targetFile, final XmlEntityDecl.EntityContextType type, final XmlEntityRef entityRef)
{
    CachedValue<PsiElement> value = entityRef.getUserData(PARSED_DECL_KEY);

    if(value == null)
    {
        value = CachedValuesManager.getManager(entityDecl.getProject()).createCachedValue(() ->
        {
            final PsiElement res = entityDecl.parse(targetFile, type, entityRef);
            if(res == null)
            {
                return new CachedValueProvider.Result<>(res, targetFile);
            }
            if(!entityDecl.isInternalReference())
            {
                XmlEntityCache.copyEntityCaches(res.getContainingFile(), targetFile);
            }
            return new CachedValueProvider.Result<>(res, res.getUserData(XmlElement.DEPENDING_ELEMENT), entityDecl, targetFile, entityRef);
        }, false);
        value = ((XmlEntityRefImpl) entityRef).putUserDataIfAbsent(PARSED_DECL_KEY, value);
    }

    return value.getValue();
}
项目:consulo-xml    文件:DtdReferencesProvider.java   
@Override
@Nullable
public PsiElement resolve()
{
    XmlEntityDecl xmlEntityDecl = XmlEntityRefImpl.resolveEntity((XmlElement) myElement, (myElement instanceof XmlEntityRef ? myElement.getLastChild() : myElement).getText(), myElement
            .getContainingFile());

    if(xmlEntityDecl != null && !xmlEntityDecl.isPhysical())
    {
        PsiNamedElement element = XmlUtil.findRealNamedElement(xmlEntityDecl);
        if(element != null)
        {
            xmlEntityDecl = (XmlEntityDecl) element;
        }
    }
    return xmlEntityDecl;
}
项目:intellij-ce-playground    文件:DtdReferencesProvider.java   
@Override
@Nullable
public PsiElement resolve() {
  XmlEntityDecl xmlEntityDecl = XmlEntityRefImpl.resolveEntity(
    (XmlElement)myElement,
    (myElement instanceof  XmlEntityRef ? myElement.getLastChild():myElement).getText(),
    myElement.getContainingFile()
  );

  if (xmlEntityDecl != null && !xmlEntityDecl.isPhysical()) {
    PsiNamedElement element = XmlUtil.findRealNamedElement(xmlEntityDecl);
    if (element != null) xmlEntityDecl = (XmlEntityDecl)element;
  }
  return xmlEntityDecl;
}
项目:tools-idea    文件:DtdReferencesProvider.java   
@Nullable
public PsiElement resolve() {
  XmlEntityDecl xmlEntityDecl = XmlEntityRefImpl.resolveEntity(
    (XmlElement)myElement,
    (myElement instanceof  XmlEntityRef ? myElement.getLastChild():myElement).getText(),
    myElement.getContainingFile()
  );

  if (xmlEntityDecl != null && !xmlEntityDecl.isPhysical()) {
    PsiNamedElement element = XmlUtil.findRealNamedElement(xmlEntityDecl);
    if (element != null) xmlEntityDecl = (XmlEntityDecl)element;
  }
  return xmlEntityDecl;
}
项目:consulo-xml    文件:XmlUtil.java   
public static String generateDocumentDTD(XmlDocument doc, boolean full)
{
    final Map<String, List<String>> tags = new LinkedHashMap<>();
    final Map<String, List<MyAttributeInfo>> attributes = new LinkedHashMap<>();

    try
    {
        XmlEntityRefImpl.setNoEntityExpandOutOfDocument(doc, true);
        final XmlTag rootTag = doc.getRootTag();
        computeTag(rootTag, tags, attributes, full);

        // For supporting not well-formed XML
        for(PsiElement element = rootTag != null ? rootTag.getNextSibling() : null; element != null; element = element.getNextSibling())
        {
            if(element instanceof XmlTag)
            {
                computeTag((XmlTag) element, tags, attributes, full);
            }
        }
    }
    finally
    {
        XmlEntityRefImpl.setNoEntityExpandOutOfDocument(doc, false);
    }

    final StringBuilder buffer = new StringBuilder();
    for(final String tagName : tags.keySet())
    {
        buffer.append(generateElementDTD(tagName, tags.get(tagName), attributes.get(tagName)));
    }
    return buffer.toString();
}