Java 类com.intellij.util.xml.reflect.DomChildrenDescription 实例源码

项目:intellij-ce-playground    文件:DomSemContributor.java   
@Nullable
private static <T extends DomChildrenDescription> T findChildrenDescription(List<T> descriptions, XmlTag tag, DomInvocationHandler parent) {
  final String localName = tag.getLocalName();
  String namespace = null;
  final String qName = tag.getName();

  final XmlFile file = parent.getFile();

  //noinspection ForLoopReplaceableByForEach
  for (int i = 0, size = descriptions.size(); i < size; i++) {
    final T description = descriptions.get(i);
    final XmlName xmlName = description.getXmlName();

    if (localName.equals(xmlName.getLocalName()) || qName.equals(xmlName.getLocalName())) {
      final EvaluatedXmlName evaluatedXmlName = parent.createEvaluatedXmlName(xmlName);
      if (DomImplUtil.isNameSuitable(evaluatedXmlName,
                                     localName,
                                     qName,
                                     namespace == null ? namespace = tag.getNamespace() : namespace,
                                     file)) {
        return description;
      }
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:DomElementPattern.java   
public Self withChild(@NonNls @NotNull final String localName, final ElementPattern pattern) {
  return with(new PatternCondition<T>("withChild") {
    @Override
    public boolean accepts(@NotNull final T t, final ProcessingContext context) {
      for (final AbstractDomChildrenDescription description : t.getGenericInfo().getChildrenDescriptions()) {
        if (!(description instanceof DomChildrenDescription) || localName.equals(((DomChildrenDescription)description).getXmlElementName())) {
          for (final DomElement element : description.getValues(t)) {
            if (localName.equals(element.getXmlElementName()) && pattern.accepts(element, context)) {
              return true;
            }
          }
        }
      }
      return false;
    }
  });
}
项目:intellij-ce-playground    文件:BasicDomElementComponent.java   
private JComponent getBoundComponent(final AbstractDomChildrenDescription description) {
  for (Field field : getClass().getDeclaredFields()) {
    try {
      field.setAccessible(true);

      if (description instanceof DomChildrenDescription) {
        final DomChildrenDescription childrenDescription = (DomChildrenDescription)description;
        if (convertFieldName(field.getName(), childrenDescription).equals(childrenDescription.getXmlElementName()) && field.get(this) instanceof JComponent) {
          return (JComponent)field.get(this);
        }
      }
    }
    catch (IllegalAccessException e) {
      LOG.error(e);
    }
  }

  return null;
}
项目:tools-idea    文件:DomSemContributor.java   
@Nullable
private static <T extends DomChildrenDescription> T findChildrenDescription(List<T> descriptions, XmlTag tag, DomInvocationHandler parent) {
  final String localName = tag.getLocalName();
  String namespace = null;
  final String qName = tag.getName();

  final XmlFile file = parent.getFile();

  //noinspection ForLoopReplaceableByForEach
  for (int i = 0, size = descriptions.size(); i < size; i++) {
    final T description = descriptions.get(i);
    final XmlName xmlName = description.getXmlName();

    if (localName.equals(xmlName.getLocalName()) || qName.equals(xmlName.getLocalName())) {
      final EvaluatedXmlName evaluatedXmlName = parent.createEvaluatedXmlName(xmlName);
      if (DomImplUtil.isNameSuitable(evaluatedXmlName,
                                     localName,
                                     qName,
                                     namespace == null ? namespace = tag.getNamespace() : namespace,
                                     file)) {
        return description;
      }
    }
  }
  return null;
}
项目:tools-idea    文件:DomElementPattern.java   
public Self withChild(@NonNls @NotNull final String localName, final ElementPattern pattern) {
  return with(new PatternCondition<T>("withChild") {
    public boolean accepts(@NotNull final T t, final ProcessingContext context) {
      for (final AbstractDomChildrenDescription description : t.getGenericInfo().getChildrenDescriptions()) {
        if (!(description instanceof DomChildrenDescription) || localName.equals(((DomChildrenDescription)description).getXmlElementName())) {
          for (final DomElement element : description.getValues(t)) {
            if (localName.equals(element.getXmlElementName()) && pattern.getCondition().accepts(element, context)) {
              return true;
            }
          }
        }
      }
      return false;
    }
  });
}
项目:tools-idea    文件:BasicDomElementComponent.java   
private JComponent getBoundComponent(final AbstractDomChildrenDescription description) {
  for (Field field : getClass().getDeclaredFields()) {
    try {
      field.setAccessible(true);

      if (description instanceof DomChildrenDescription) {
        final DomChildrenDescription childrenDescription = (DomChildrenDescription)description;
        if (convertFieldName(field.getName(), childrenDescription).equals(childrenDescription.getXmlElementName()) && field.get(this) instanceof JComponent) {
          return (JComponent)field.get(this);
        }
      }
    }
    catch (IllegalAccessException e) {
      LOG.error(e);
    }
  }

  return null;
}
项目:consulo-xml    文件:DomSemContributor.java   
@Nullable
private static <T extends DomChildrenDescription> T findChildrenDescription(List<T> descriptions, XmlTag tag, DomInvocationHandler parent) {
  final String localName = tag.getLocalName();
  String namespace = null;
  final String qName = tag.getName();

  final XmlFile file = parent.getFile();

  //noinspection ForLoopReplaceableByForEach
  for (int i = 0, size = descriptions.size(); i < size; i++) {
    final T description = descriptions.get(i);
    final XmlName xmlName = description.getXmlName();

    if (localName.equals(xmlName.getLocalName()) || qName.equals(xmlName.getLocalName())) {
      final EvaluatedXmlName evaluatedXmlName = parent.createEvaluatedXmlName(xmlName);
      if (DomImplUtil.isNameSuitable(evaluatedXmlName,
                                     localName,
                                     qName,
                                     namespace == null ? namespace = tag.getNamespace() : namespace,
                                     file)) {
        return description;
      }
    }
  }
  return null;
}
项目:consulo-xml    文件:DomElementPattern.java   
public Self withChild(@NonNls @NotNull final String localName, final ElementPattern pattern) {
  return with(new PatternCondition<T>("withChild") {
    public boolean accepts(@NotNull final T t, final ProcessingContext context) {
      for (final AbstractDomChildrenDescription description : t.getGenericInfo().getChildrenDescriptions()) {
        if (!(description instanceof DomChildrenDescription) || localName.equals(((DomChildrenDescription)description).getXmlElementName())) {
          for (final DomElement element : description.getValues(t)) {
            if (localName.equals(element.getXmlElementName()) && pattern.getCondition().accepts(element, context)) {
              return true;
            }
          }
        }
      }
      return false;
    }
  });
}
项目:consulo-xml    文件:BasicDomElementComponent.java   
private JComponent getBoundComponent(final AbstractDomChildrenDescription description) {
  for (Field field : getClass().getDeclaredFields()) {
    try {
      field.setAccessible(true);

      if (description instanceof DomChildrenDescription) {
        final DomChildrenDescription childrenDescription = (DomChildrenDescription)description;
        if (convertFieldName(field.getName(), childrenDescription).equals(childrenDescription.getXmlElementName()) && field.get(this) instanceof JComponent) {
          return (JComponent)field.get(this);
        }
      }
    }
    catch (IllegalAccessException e) {
      LOG.error(e);
    }
  }

  return 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    文件:BasicDomElementComponent.java   
private String convertFieldName(String propertyName, final DomChildrenDescription description) {
  if (propertyName.startsWith("my")) propertyName = propertyName.substring(2);

  String convertedName = description.getDomNameStrategy(getDomElement()).convertName(propertyName);

  if (description instanceof DomCollectionChildDescription) {
    final String unpluralizedStr = StringUtil.unpluralize(convertedName);

    if (unpluralizedStr != null) return unpluralizedStr;
  }
  return convertedName;
}
项目:tools-idea    文件:BasicDomElementComponent.java   
private String convertFieldName(String propertyName, final DomChildrenDescription description) {
  if (propertyName.startsWith("my")) propertyName = propertyName.substring(2);

  String convertedName = description.getDomNameStrategy(getDomElement()).convertName(propertyName);

  if (description instanceof DomCollectionChildDescription) {
    final String unpluralizedStr = StringUtil.unpluralize(convertedName);

    if (unpluralizedStr != null) return unpluralizedStr;
  }
  return convertedName;
}
项目:consulo-xml    文件:BasicDomElementComponent.java   
private String convertFieldName(String propertyName, final DomChildrenDescription description) {
  if (propertyName.startsWith("my")) propertyName = propertyName.substring(2);

  String convertedName = description.getDomNameStrategy(getDomElement()).convertName(propertyName);

  if (description instanceof DomCollectionChildDescription) {
    final String unpluralizedStr = StringUtil.unpluralize(convertedName);

    if (unpluralizedStr != null) return unpluralizedStr;
  }
  return convertedName;
}
项目:intellij-ce-playground    文件:DomElementXmlDescriptor.java   
public DomElementXmlDescriptor(@NotNull final DomChildrenDescription childrenDescription, final DomManager manager) {
  super(manager);
  myChildrenDescription = childrenDescription;
}
项目:tools-idea    文件:DomElementXmlDescriptor.java   
public DomElementXmlDescriptor(@NotNull final DomChildrenDescription childrenDescription, final DomManager manager) {
  super(manager);
  myChildrenDescription = childrenDescription;
}
项目:consulo-xml    文件:DomElementXmlDescriptor.java   
public DomElementXmlDescriptor(@NotNull final DomChildrenDescription childrenDescription, final DomManager manager)
{
    super(manager);
    myChildrenDescription = childrenDescription;
}
项目: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());
    }
}