com.intellij.psi.xml.XmlTag.getSubTags()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(142)

本文整理了Java中com.intellij.psi.xml.XmlTag.getSubTags()方法的一些代码示例,展示了XmlTag.getSubTags()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlTag.getSubTags()方法的具体详情如下:
包路径:com.intellij.psi.xml.XmlTag
类名称:XmlTag
方法名:getSubTags

XmlTag.getSubTags介绍

暂无

代码示例

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

@NotNull
public static Collection<XmlTag> getXmlContainerServiceDefinition(PsiFile psiFile) {
  Collection<XmlTag> xmlTags = new ArrayList<>();
  for(XmlTag xmlTag: PsiTreeUtil.getChildrenOfTypeAsList(psiFile.getFirstChild(), XmlTag.class)) {
    if(xmlTag.getName().equals("container")) {
      for(XmlTag servicesTag: xmlTag.getSubTags()) {
        if(servicesTag.getName().equals("services")) {
          for(XmlTag parameterTag: servicesTag.getSubTags()) {
            if(parameterTag.getName().equals("service")) {
              xmlTags.add(parameterTag);
            }
          }
        }
      }
    }
  }
  return xmlTags;
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

public static Set<String> getTags(XmlTag serviceTag) {
  Set<String> tags = new HashSet<>();
  for(XmlTag serviceSubTag: serviceTag.getSubTags()) {
    if("tag".equals(serviceSubTag.getName())) {
      XmlAttribute attribute = serviceSubTag.getAttribute("name");
      if(attribute != null) {
        String tagName = attribute.getValue();
        if(tagName != null && StringUtils.isNotBlank(tagName)) {
          tags.add(tagName);
        }
      }
    }
  }
  return tags;
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

/**
 * <route controller="Foo"/>
 * <route>
 *     <default key="_controller">Foo</default>
 * </route>
 */
@Nullable
public static String getXmlController(@NotNull XmlTag serviceTag) {
  for(XmlTag subTag :serviceTag.getSubTags()) {
    if("default".equalsIgnoreCase(subTag.getName())) {
      String keyValue = subTag.getAttributeValue("key");
      if(keyValue != null && "_controller".equals(keyValue)) {
        String actionName = subTag.getValue().getTrimmedText();
        if(StringUtils.isNotBlank(actionName)) {
          return actionName;
        }
      }
    }
  }
  String controller = serviceTag.getAttributeValue("controller");
  if(controller != null && StringUtils.isNotBlank(controller)) {
    return controller;
  }
  return null;
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

@Nullable
public static PsiElement getLocalServiceName(PsiFile psiFile, String serviceName) {
  if(!(psiFile.getFirstChild() instanceof XmlDocument)) {
    return null;
  }
  XmlTag xmlTags[] = PsiTreeUtil.getChildrenOfType(psiFile.getFirstChild(), XmlTag.class);
  if(xmlTags == null) {
    return null;
  }
  for(XmlTag xmlTag: xmlTags) {
    if(xmlTag.getName().equals("container")) {
      for(XmlTag servicesTag: xmlTag.getSubTags()) {
        if(servicesTag.getName().equals("services")) {
          for(XmlTag serviceTag: servicesTag.getSubTags()) {
            String serviceNameId = serviceTag.getAttributeValue("id");
            if(serviceNameId != null && serviceNameId.equalsIgnoreCase(serviceName)) {
              return serviceTag;
            }
          }
        }
      }
    }
  }
  return null;
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

@NotNull
public static List<String> getXmlMissingArgumentTypes(@NotNull XmlTag xmlTag, boolean collectOptionalParameter, @NotNull ContainerCollectionResolver.LazyServiceCollector collector) {
  PhpClass resolvedClassDefinition = getPhpClassFromXmlTag(xmlTag, collector);
  if (resolvedClassDefinition == null) {
    return Collections.emptyList();
  }
  Method constructor = resolvedClassDefinition.getConstructor();
  if(constructor == null) {
    return Collections.emptyList();
  }
  int serviceArguments = 0;
  for (XmlTag tag : xmlTag.getSubTags()) {
    if("argument".equals(tag.getName())) {
      serviceArguments++;
    }
  }
  Parameter[] parameters = collectOptionalParameter ? constructor.getParameters() : PhpElementsUtil.getFunctionRequiredParameter(constructor);
  if(parameters.length <= serviceArguments) {
    return Collections.emptyList();
  }
  final List<String> args = new ArrayList<>();
  for (int i = serviceArguments; i < parameters.length; i++) {
    Parameter parameter = parameters[i];
    String s = parameter.getDeclaredType().toString();
    args.add(s);
  }
  return args;
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

@Nullable
public static PsiElement getXmlRouteNameTarget(@NotNull XmlFile psiFile,@NotNull String routeName) {
  XmlDocumentImpl document = PsiTreeUtil.getChildOfType(psiFile, XmlDocumentImpl.class);
  if(document == null) {
    return null;
  }
  for(XmlTag xmlTag: PsiTreeUtil.getChildrenOfTypeAsList(psiFile.getFirstChild(), XmlTag.class)) {
    if(xmlTag.getName().equals("routes")) {
      for(XmlTag routeTag: xmlTag.getSubTags()) {
        if(routeTag.getName().equals("route")) {
          XmlAttribute xmlAttribute = routeTag.getAttribute("id");
          if(xmlAttribute != null) {
            String attrValue = xmlAttribute.getValue();
            if(routeName.equals(attrValue)) {
              return xmlAttribute;
            }
          }
        }
      }
    }
  }
  return null;
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

for(XmlTag servicesTag: xmlTag.getSubTags()) {
  if(servicesTag.getName().equals(root)) {
    for(XmlTag parameterTag: servicesTag.getSubTags()) {
      if(parameterTag.getName().equals(child)) {
        XmlAttribute keyAttr = parameterTag.getAttribute(tagName);

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

@Nullable
public static PsiElement getLocalParameterName(PsiFile psiFile, String serviceName) {
  if(!(psiFile.getFirstChild() instanceof XmlDocumentImpl)) {
    return null;
  }
  XmlTag xmlTags[] = PsiTreeUtil.getChildrenOfType(psiFile.getFirstChild(), XmlTag.class);
  if(xmlTags == null) {
    return null;
  }
  for(XmlTag xmlTag: xmlTags) {
    if(xmlTag.getName().equals("container")) {
      for(XmlTag servicesTag: xmlTag.getSubTags()) {
        if(servicesTag.getName().equals("parameters")) {
          for(XmlTag serviceTag: servicesTag.getSubTags()) {
            XmlAttribute attrValue = serviceTag.getAttribute("key");
            if(attrValue != null) {
              String serviceNameId = attrValue.getValue();
              if(serviceNameId != null && serviceNameId.equals(serviceName)) {
                return serviceTag;
              }
            }
          }
        }
      }
    }
  }
  return null;
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

private void getOdmFields(@NotNull XmlTag xmlTag, @NotNull Collection<DoctrineModelField> fields) {
    for (XmlTag tag : xmlTag.getSubTags()) {
      String tagName = tag.getName();
      if("field".equals(tagName)) {
        String name = tag.getAttributeValue("name");
        if(StringUtils.isNotBlank(name)) {
          DoctrineModelField type = new DoctrineModelField(name, tag.getAttributeValue("type"));
          type.setColumn(tag.getAttributeValue("fieldName"));
          fields.add(type);
        }
      } else if(RELATIONS.contains(tagName)) {
        String field = tag.getAttributeValue("field");
        if(StringUtils.isNotBlank(field)) {
          DoctrineModelField type = new DoctrineModelField(field);
          type.setRelationType(tagName);
          type.setRelation(tag.getAttributeValue("target-document"));
          fields.add(type);
        }
      }
    }
  }
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

for(XmlTag servicesTag: xmlTag.getSubTags()) {
  if(servicesTag.getName().equals("parameters")) {
    for(XmlTag parameterTag: servicesTag.getSubTags()) {
            if(!"collection".equals(typeAttr) && parameterTag.getSubTags().length == 0) {
              XmlTagValue attrClass = parameterTag.getValue();
              String myParameterValue = attrClass.getText();

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

for(XmlTag servicesTag: xmlTag.getSubTags()) {
  if(servicesTag.getName().equals("services")) {
    for(XmlTag serviceTag: servicesTag.getSubTags()) {
      XmlAttribute attrValue = serviceTag.getAttribute("id");
      if(attrValue != null) {

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

public static void visitFile(@NotNull XmlFile psiFile, @NotNull Consumer<ServiceConsumer> consumer) {
  if(!(psiFile.getFirstChild() instanceof XmlDocument)) {
    return;
  }
  XmlTag xmlTags[] = PsiTreeUtil.getChildrenOfType(psiFile.getFirstChild(), XmlTag.class);
  if(xmlTags == null) {
    return;
  }
  for(XmlTag xmlTag: xmlTags) {
    if(xmlTag.getName().equals("container")) {
      for(XmlTag servicesTag: xmlTag.getSubTags()) {
        if("services".equals(servicesTag.getName())) {
          // default values:
          // <defaults autowire="true" public="false" />
          ServiceFileDefaults defaults = createDefaults(servicesTag);
          for(XmlTag serviceTag: servicesTag.findSubTags("service")) {
            String serviceId = serviceTag.getAttributeValue("id");
            if(StringUtils.isBlank(serviceId)) {
              continue;
            }
            consumer.consume(new ServiceConsumer(serviceTag, serviceId, new XmlTagAttributeValue(serviceTag), defaults));
          }
        }
      }
    }
  }
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

DoctrineMetadataModel model = new DoctrineMetadataModel(fields);
for (XmlTag xmlTag : rootTag.getSubTags()) {
  String name = xmlTag.getAttributeValue("name");
  if(name == null) {

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

for(XmlTag servicesTag: xmlTag.getSubTags()) {
  if(servicesTag.getName().equals("route")) {
    XmlAttribute xmlAttribute = servicesTag.getAttribute("id");

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

for (XmlTag tag : xmlTag.getSubTags()) {

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

if(argumentTag instanceof XmlTag && "argument".equals(((XmlTag) argumentTag).getName()) && ((XmlTag) argumentTag).getSubTags().length == 0) {
  PsiElement serviceTag = argumentTag.getParent();
  if(serviceTag instanceof XmlTag && "service".equals(((XmlTag) serviceTag).getName())) {

代码示例来源:origin: misakuo/svgtoandroid

public List<XmlTag> getSubGroups(XmlTag parent) {
  List<XmlTag> list = new ArrayList<XmlTag>();
  for (XmlTag tag : parent.getSubTags()) {
    if (tag.getName().equals("g")) {
      list.add(tag);
    }
  }
  return list;
}

代码示例来源:origin: misakuo/svgtoandroid

public List<XmlTag> getUseTags(XmlTag parentTag) {
  List<XmlTag> tags = new ArrayList<XmlTag>();
  XmlTag[] subTags = parentTag.getSubTags();
  for (XmlTag tag : subTags) {
    if ("use".equalsIgnoreCase(tag.getName())) {
      tags.add(tag);
    }
  }
  Logger.debug("use tags of " + parentTag.getName() + " :" + tags.toString());
  return tags;
}

代码示例来源:origin: misakuo/svgtoandroid

public List<XmlTag> getSVGChildes() {
  List<XmlTag> childes = new ArrayList<XmlTag>();
  if (svg.getDocument() != null) {
    XmlTag rootTag = svg.getDocument().getRootTag();
    if (rootTag != null) {
      Collections.addAll(childes, rootTag.getSubTags());
    }
  }
  return childes;
}

代码示例来源:origin: misakuo/svgtoandroid

public List<XmlTag> getShapeTags(XmlTag parentTag) {
  List<XmlTag> tags = new ArrayList<XmlTag>();
  XmlTag[] subTags = parentTag.getSubTags();
  for (XmlTag tag : subTags) {
    if (AttrMapper.isShapeName(tag.getName())) {
      tags.add(tag);
    }
  }
  Logger.debug("shapeTag of " + parentTag.getName() + " :" + tags.toString());
  return tags;
}

相关文章