Java 类com.intellij.util.xml.stubs.AttributeStub 实例源码

项目:tools-idea    文件:DomInvocationHandler.java   
@NotNull
final AttributeChildInvocationHandler getAttributeChild(final AttributeChildDescriptionImpl description) {
  final EvaluatedXmlName evaluatedXmlName = createEvaluatedXmlName(description.getXmlName());
  if (myStub != null && description.isStubbed()) {
    AttributeStub stub = myStub.getAttributeStub(description.getXmlName());
    StubParentStrategy strategy = StubParentStrategy.createAttributeStrategy(stub, myStub);
    return new AttributeChildInvocationHandler(evaluatedXmlName, description, myManager, strategy, stub);
  }
  final XmlTag tag = getXmlTag();

  if (tag != null) {
    // TODO: this seems ugly
    String ns = evaluatedXmlName.getNamespace(tag, getFile());
    final XmlAttribute attribute = tag.getAttribute(description.getXmlName().getLocalName(), ns.equals(tag.getNamespace())? null:ns);

    if (attribute != null) {
      LOG.assertTrue(attribute.isValid());
      return myManager.getSemService().getSemElement(DomManagerImpl.DOM_ATTRIBUTE_HANDLER_KEY, attribute);
    }
  }
  return new AttributeChildInvocationHandler(evaluatedXmlName, description, myManager, new VirtualDomParentStrategy(this), null);
}
项目:consulo-xml    文件:DomInvocationHandler.java   
@NotNull
final AttributeChildInvocationHandler getAttributeChild(final AttributeChildDescriptionImpl description) {
  final EvaluatedXmlName evaluatedXmlName = createEvaluatedXmlName(description.getXmlName());
  if (myStub != null && description.isStubbed()) {
    AttributeStub stub = myStub.getAttributeStub(description.getXmlName());
    StubParentStrategy strategy = StubParentStrategy.createAttributeStrategy(stub, myStub);
    return new AttributeChildInvocationHandler(evaluatedXmlName, description, myManager, strategy, stub);
  }
  final XmlTag tag = getXmlTag();

  if (tag != null) {
    // TODO: this seems ugly
    String ns = evaluatedXmlName.getNamespace(tag, getFile());
    final XmlAttribute attribute = tag.getAttribute(description.getXmlName().getLocalName(), ns.equals(tag.getNamespace())? null:ns);

    if (attribute != null) {
      LOG.assertTrue(attribute.isValid());
      return myManager.getSemService().getSemElement(DomManagerImpl.DOM_ATTRIBUTE_HANDLER_KEY, attribute);
    }
  }
  return new AttributeChildInvocationHandler(evaluatedXmlName, description, myManager, new VirtualDomParentStrategy(this), null);
}
项目: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());
  }
}
项目:intellij-ce-playground    文件:DomInvocationHandler.java   
@NotNull
final AttributeChildInvocationHandler getAttributeChild(final AttributeChildDescriptionImpl description) {
  final EvaluatedXmlName evaluatedXmlName = createEvaluatedXmlName(description.getXmlName());
  if (myStub != null && description.isStubbed()) {
    AttributeStub stub = myStub.getAttributeStub(description.getXmlName());
    StubParentStrategy strategy = StubParentStrategy.createAttributeStrategy(stub, myStub);
    return new AttributeChildInvocationHandler(evaluatedXmlName, description, myManager, strategy, stub);
  }
  final XmlTag tag = getXmlTag();

  if (tag != null) {
    // TODO: this seems ugly
    String ns = evaluatedXmlName.getNamespace(tag, getFile());
    final XmlAttribute attribute = tag.getAttribute(description.getXmlName().getLocalName(), ns.equals(tag.getNamespace())? null:ns);

    if (attribute != null) {
      PsiUtilCore.ensureValid(attribute);
      AttributeChildInvocationHandler semElement =
        myManager.getSemService().getSemElement(DomManagerImpl.DOM_ATTRIBUTE_HANDLER_KEY, attribute);
      if (semElement == null) {
        final AttributeChildInvocationHandler take2 = myManager.getSemService().getSemElement(DomManagerImpl.DOM_ATTRIBUTE_HANDLER_KEY, attribute);
        throw new AssertionError("No DOM at XML. Parent=" + tag + "; attribute=" + attribute + "; second attempt=" + take2);
      }
      return semElement;
    }
  }
  return new AttributeChildInvocationHandler(evaluatedXmlName, description, myManager, new VirtualDomParentStrategy(this), null);
}
项目:intellij-ce-playground    文件:AttributeChildInvocationHandler.java   
protected AttributeChildInvocationHandler(final EvaluatedXmlName attributeName,
                                          final AttributeChildDescriptionImpl description,
                                          final DomManagerImpl manager,
                                          final DomParentStrategy strategy,
                                          @Nullable AttributeStub stub) {
  super(description.getType(), strategy, attributeName, description, manager, false, stub);
}
项目:tools-idea    文件:AttributeChildInvocationHandler.java   
protected AttributeChildInvocationHandler(final EvaluatedXmlName attributeName,
                                          final AttributeChildDescriptionImpl description,
                                          final DomManagerImpl manager,
                                          final DomParentStrategy strategy,
                                          @Nullable AttributeStub stub) {
  super(description.getType(), strategy, attributeName, description, manager, false, stub);
}
项目:consulo-xml    文件:AttributeChildInvocationHandler.java   
protected AttributeChildInvocationHandler(final EvaluatedXmlName attributeName,
                                          final AttributeChildDescriptionImpl description,
                                          final DomManagerImpl manager,
                                          final DomParentStrategy strategy,
                                          @Nullable AttributeStub stub) {
  super(description.getType(), strategy, attributeName, description, manager, false, stub);
}
项目: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());
    }
}