gpt4 book ai didi

fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper.collectServiceTags()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 14:09:31 27 4
gpt4 key购买 nike

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

YamlHelper.collectServiceTags介绍

[英]Collect defined service tags on a sequence list - { name: assetic.factory_worker } - [ assetic.factory_worker ]
[中]

代码示例

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

/**
 * acme_demo.form.type.gender:
 *  class: espend\Form\TypeBundle\Form\FooType
 *  tags:
 *   - { name: form.type, alias: foo_type_alias  }
 *   - { name: foo  }
 */
@NotNull
public static Map<String, Set<String>> getTags(@NotNull YAMLFile yamlFile) {
  Map<String, Set<String>> map = new HashMap<>();
  for(YAMLKeyValue yamlServiceKeyValue : YamlHelper.getQualifiedKeyValuesInFile(yamlFile, "services")) {
    String serviceName = yamlServiceKeyValue.getName();
    Set<String> serviceTagMap = YamlHelper.collectServiceTags(yamlServiceKeyValue);
    if(serviceTagMap != null && serviceTagMap.size() > 0) {
      map.put(serviceName, serviceTagMap);
    }
  }
  return map;
}

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

@Nullable
private static Pair<PhpClass, Set<String>> invoke(@NotNull Project project, @NotNull YAMLKeyValue serviceKeyValue) {
  String aClass = YamlHelper.getYamlKeyValueAsString(serviceKeyValue, "class");
  if(aClass == null|| StringUtils.isBlank(aClass)) {
    return null;
  }
  PhpClass resolvedClassDefinition = ServiceUtil.getResolvedClassDefinition(project, aClass, new ContainerCollectionResolver.LazyServiceCollector(project));
  if(resolvedClassDefinition == null) {
    return null;
  }
  Set<String> phpClassServiceTags = ServiceUtil.getPhpClassServiceTags(resolvedClassDefinition);
  Set<String> strings = YamlHelper.collectServiceTags(serviceKeyValue);
  if(strings != null && strings.size() > 0) {
    for (String s : strings) {
      if(phpClassServiceTags.contains(s)) {
        phpClassServiceTags.remove(s);
      }
    }
  }
  return Pair.create(resolvedClassDefinition, phpClassServiceTags);
}

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

@Override
public void visitElement(PsiElement element) {
  if(YamlElementPatternHelper.getSingleLineScalarKey("class").accepts(element)) {
    // class: '\Foo'
    String text = PsiElementUtils.trimQuote(element.getText());
    if(StringUtils.isBlank(text)) {
      super.visitElement(element);
      return;
    }
    PsiElement yamlScalar = element.getParent();
    if(!(yamlScalar instanceof YAMLScalar)) {
      super.visitElement(element);
      return;
    }
    PsiElement classKey = yamlScalar.getParent();
    if(classKey instanceof YAMLKeyValue) {
      PsiElement yamlCompoundValue = classKey.getParent();
      if(yamlCompoundValue instanceof YAMLCompoundValue) {
        PsiElement serviceKeyValue = yamlCompoundValue.getParent();
        if(serviceKeyValue instanceof YAMLKeyValue) {
          Set<String> tags = YamlHelper.collectServiceTags((YAMLKeyValue) serviceKeyValue);
          if(tags != null && tags.size() > 0) {
            registerTaggedProblems(element, tags, text, holder, this.lazyServiceCollector);
          }
        }
      }
    }
  }
  super.visitElement(element);
}

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

/**
 * @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#collectServiceTags
 */
public void testCollectServiceTags() {
  YAMLKeyValue fromText = YamlPsiElementFactory.createFromText(getProject(), YAMLKeyValue.class, "" +
    "foo:\n" +
    "  tags:\n" +
    "    - { name: routing.loader, method: crossHint }\n" +
    "    - { name: routing.loader1, method: crossHint }\n"
  );
  assertNotNull(fromText);
  assertContainsElements(YamlHelper.collectServiceTags(fromText), "routing.loader", "routing.loader1");
}

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

/**
 * @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#collectServiceTags
 */
public void testCollectServiceTagsForSymfony33TagsShortcutInline() {
  YAMLKeyValue fromText = YamlPsiElementFactory.createFromText(getProject(), YAMLKeyValue.class, "" +
    "foo:\n" +
    "  tags: [routing.loader_tags_3, routing.loader_tags_4]\n"
  );
  assertNotNull(fromText);
  Set<String> collection = YamlHelper.collectServiceTags(fromText);
  assertContainsElements(collection, "routing.loader_tags_3");
  assertContainsElements(collection, "routing.loader_tags_4");
}

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

/**
 * @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#collectServiceTags
 */
public void testCollectServiceTagsForSymfony33TagsShortcut() {
  YAMLKeyValue fromText = YamlPsiElementFactory.createFromText(getProject(), YAMLKeyValue.class, "" +
    "foo:\n" +
    "  tags:\n" +
    "    - routing.loader_tags_1\n" +
    "    - routing.loader_tags_2\n"
  );
  assertNotNull(fromText);
  Set<String> collection = YamlHelper.collectServiceTags(fromText);
  assertContainsElements(collection, "routing.loader_tags_1");
  assertContainsElements(collection, "routing.loader_tags_2");
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com