Java 类com.intellij.util.xml.StubbedOccurrence 实例源码

项目:intellij-ce-playground    文件:DomStubBuilderVisitor.java   
void visitXmlElement(XmlElement element, ElementStub parent, int index) {
  DomInvocationHandler handler = myManager.getDomHandler(element);
  if (handler == null || handler.getAnnotation(Stubbed.class) == null && !handler.getChildDescription().isStubbed()) return;

  AbstractDomChildrenDescription description = handler.getChildDescription();
  String nsKey = description instanceof DomChildrenDescription ? ((DomChildrenDescription)description).getXmlName().getNamespaceKey() : "";
  if (element instanceof XmlTag) {
    XmlTag tag = (XmlTag)element;

    String elementClass = null;
    if (handler.getAnnotation(StubbedOccurrence.class) != null) {
      final Type type = description.getType();
      elementClass = ((Class)type).getName();
    }
    ElementStub stub = new ElementStub(parent,
                                       StringRef.fromString(tag.getName()),
                                       StringRef.fromNullableString(nsKey),
                                       index,
                                       description instanceof CustomDomChildrenDescription,
                                       elementClass == null ? null : StringRef.fromNullableString(elementClass),
                                       tag.getSubTags().length == 0 ? tag.getValue().getTrimmedText() : "");

    for (XmlAttribute attribute : tag.getAttributes()) {
      visitXmlElement(attribute, stub, 0);
    }
    Map<String, Integer> indices = new HashMap<String, Integer>();
    for (final XmlTag subTag : tag.getSubTags()) {
      String name = subTag.getName();
      Integer i = indices.get(name);
      i = i == null ? 0 : i + 1;
      visitXmlElement(subTag, stub, i);
      indices.put(name, i);
    }
  } else if (element instanceof XmlAttribute) {
    new AttributeStub(parent, StringRef.fromString(((XmlAttribute)element).getLocalName()), 
                      StringRef.fromNullableString(nsKey), 
                      ((XmlAttribute)element).getValue());
  }
}
项目:consulo-xml    文件:DomStubBuilderVisitor.java   
void visitXmlElement(XmlElement element, ElementStub parent, int index)
{
    DomInvocationHandler handler = myManager.getDomHandler(element);
    if(handler == null || handler.getAnnotation(Stubbed.class) == null && !handler.getChildDescription().isStubbed())
    {
        return;
    }

    AbstractDomChildrenDescription description = handler.getChildDescription();
    String nsKey = description instanceof DomChildrenDescription ? ((DomChildrenDescription) description).getXmlName().getNamespaceKey() : "";
    if(element instanceof XmlTag)
    {
        XmlTag tag = (XmlTag) element;

        String elementClass = null;
        if(handler.getAnnotation(StubbedOccurrence.class) != null)
        {
            final Type type = description.getType();
            elementClass = ((Class) type).getName();
        }

        ElementStub stub = new ElementStub(parent, StringRef.fromString(tag.getName()), StringRef.fromNullableString(nsKey), index,
                description instanceof CustomDomChildrenDescription, elementClass == null ? null : StringRef.fromNullableString(elementClass));
        for(XmlAttribute attribute : tag.getAttributes())
        {
            visitXmlElement(attribute, stub, 0);
        }
        Map<String, Integer> indices = new HashMap<String, Integer>();
        for(final XmlTag subTag : tag.getSubTags())
        {
            String name = subTag.getName();
            Integer i = indices.get(name);
            i = i == null ? 0 : i + 1;
            visitXmlElement(subTag, stub, i);
            indices.put(name, i);
        }
    }
    else if(element instanceof XmlAttribute)
    {
        new AttributeStub(parent, StringRef.fromString(((XmlAttribute) element).getLocalName()), StringRef.fromNullableString(nsKey),
                ((XmlAttribute) element).getValue());
    }
}