gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-18 13:45:31 26 4
gpt4 key购买 nike

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

YamlHelper.getYamlKeyValueAsString介绍

[英]foo: class: "name"
[中]foo:类:“名称”

代码示例

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

@Nullable
  public String getAttribute(@NotNull String attr) {
    return YamlHelper.getYamlKeyValueAsString(yamlMapping, attr);
  }
}

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

@Nullable
  @Override
  public String getString(@NotNull String key) {
    String value = YamlHelper.getYamlKeyValueAsString(yamlKeyValue, key);
    if(StringUtils.isBlank(value)) {
      return null;
    }

    return value;
  }
}

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

/**
 *  foo:
 *     class: "name"
 */
@Nullable
public static String getYamlKeyValueAsString(@NotNull YAMLKeyValue yamlKeyValue, @NotNull String keyName) {
  return getYamlKeyValueAsString(yamlKeyValue, keyName, false);
}

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

@Nullable
@Override
public String findClassForElement(@NotNull PsiElement psiElement) {
  YAMLMapping parentOfType = PsiTreeUtil.getParentOfType(psiElement, YAMLMapping.class);
  if(parentOfType == null) {
    return null;
  }
  return YamlHelper.getYamlKeyValueAsString(parentOfType, "class");
}

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

@Nullable
  @Override
  public String findIdForElement(@NotNull PsiElement psiElement) {
    YAMLMapping parentOfType = PsiTreeUtil.getParentOfType(psiElement, YAMLMapping.class);
    if(parentOfType == null) {
      return null;
    }
    return YamlHelper.getYamlKeyValueAsString(parentOfType, "id");
  }
}

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

@Nullable
public static String getYamlKeyValueAsString(@NotNull YAMLKeyValue yamlKeyValue, @NotNull String keyName, boolean ignoreCase) {
  PsiElement yamlCompoundValue = yamlKeyValue.getValue();
  if(!(yamlCompoundValue instanceof YAMLCompoundValue)) {
    return null;
  }
  return getYamlKeyValueAsString((YAMLCompoundValue) yamlCompoundValue, keyName, ignoreCase);
}

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

@Override
  protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {
    YAMLKeyValue yamlKeyValue = PsiTreeUtil.getParentOfType(completionParameters.getOriginalPosition(), YAMLKeyValue.class);
    if(yamlKeyValue != null) {
      PsiElement compoundValue = yamlKeyValue.getParent();
      if(compoundValue instanceof YAMLCompoundValue) {
        // path and pattern are valid
        String pattern = YamlHelper.getYamlKeyValueAsString((YAMLCompoundValue) compoundValue, "path", false);
        if(pattern == null) {
          pattern = YamlHelper.getYamlKeyValueAsString((YAMLCompoundValue) compoundValue, "pattern", false);
        }
        if(pattern != null) {
          Matcher matcher = Pattern.compile("\\{(\\w+)}").matcher(pattern);
          while(matcher.find()){
            completionResultSet.addElement(LookupElementBuilder.create(matcher.group(1)));
          }
        }
      }
    }
  }
}

代码示例来源: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

/**
 * Find controller definition in yaml structure
 *
 * foo:
 *   defaults: { _controller: "Bundle:Foo:Bar" }
 *   defaults:
 *      _controller: "Bundle:Foo:Bar"
 *   controller: "Bundle:Foo:Bar"
 */
@Nullable
public static String getYamlController(@NotNull YAMLKeyValue psiElement) {
  YAMLKeyValue yamlKeyValue = YamlHelper.getYamlKeyValue(psiElement, "defaults");
  if(yamlKeyValue != null) {
    final YAMLValue container = yamlKeyValue.getValue();
    if(container instanceof YAMLMapping) {
      YAMLKeyValue yamlKeyValueController = YamlHelper.getYamlKeyValue(container, "_controller", true);
      if(yamlKeyValueController != null) {
        String valueText = yamlKeyValueController.getValueText();
        if(StringUtils.isNotBlank(valueText)) {
          return valueText;
        }
      }
    }
  }
  String controller = YamlHelper.getYamlKeyValueAsString(psiElement, "controller");
  if(controller != null && StringUtils.isNotBlank(controller)) {
    return controller;
  }
  return null;
}

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

String repositoryClassValue = YamlHelper.getYamlKeyValueAsString(yamlKey, "repositoryClass");

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

String name = YamlHelper.getYamlKeyValueAsString(((YAMLMapping) value), "name");
if(name != null) {
  tags.add(name);

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

String decorates = YamlHelper.getYamlKeyValueAsString(yamlKeyValue, "decorates");
if(decorates != null && StringUtils.isNotBlank(decorates)) {
  result.add(ServiceUtil.getLineMarkerForDecoratesServiceId(leafTarget, ServiceUtil.ServiceLineMarker.DECORATE, decorates));
String parent = YamlHelper.getYamlKeyValueAsString(yamlKeyValue, "parent");
if(parent != null && StringUtils.isNotBlank(parent)) {
  result.add(ServiceUtil.getLineMarkerForDecoratesServiceId(leafTarget, ServiceUtil.ServiceLineMarker.PARENT, parent));

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

@Nullable
  public DoctrineMetadataModel getMetadata(@NotNull DoctrineMappingDriverArguments args) {

    PsiFile psiFile = args.getPsiFile();
    if(!(psiFile instanceof YAMLFile)) {
      return null;
    }

    Collection<DoctrineModelField> fields = new ArrayList<>();
    DoctrineMetadataModel model = new DoctrineMetadataModel(fields);

    for (YAMLKeyValue yamlKeyValue : YamlHelper.getTopLevelKeyValues((YAMLFile) psiFile)) {
      // first line is class name; check of we are right
      if(args.isEqualClass(YamlHelper.getYamlKeyName(yamlKeyValue))) {
        model.setTable(YamlHelper.getYamlKeyValueAsString(yamlKeyValue, "table"));
        fields.addAll(EntityHelper.getModelFieldsSet(yamlKeyValue));
      }
    }

    if(model.isEmpty()) {
      return null;
    }

    return model;
  }
}

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

@Override
  protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {
    if(!Symfony2ProjectComponent.isEnabled(completionParameters.getPosition())) {
      return;
    }
    PsiElement psiElement = completionParameters.getPosition();
    YAMLCompoundValue yamlCompoundValue = PsiTreeUtil.getParentOfType(psiElement, YAMLCompoundValue.class);
    if(yamlCompoundValue == null) {
      return;
    }
    yamlCompoundValue = PsiTreeUtil.getParentOfType(yamlCompoundValue, YAMLCompoundValue.class);
    if(yamlCompoundValue == null) {
      return;
    }
    String value = YamlHelper.getYamlKeyValueAsString(yamlCompoundValue, "class", true);
    if(value != null) {
      PhpClass phpClass = ServiceUtil.getResolvedClassDefinition(psiElement.getProject(), value);
      if(phpClass != null) {
        FormUtil.attachFormAliasesCompletions(phpClass, completionResultSet);
      }
    }
  }
}

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

@Override
protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {
  PsiElement position = completionParameters.getPosition();
  if(!Symfony2ProjectComponent.isEnabled(position)) {
    return;
  }
  YAMLCompoundValue yamlCompoundValue = PsiTreeUtil.getParentOfType(position, YAMLCompoundValue.class);
  if(yamlCompoundValue == null) {
    return;
  }
  String className = YamlHelper.getYamlKeyValueAsString(yamlCompoundValue, "targetEntity", false);
  if(className == null) {
    return;
  }
  PhpClass phpClass = PhpElementsUtil.getClass(position.getProject(), className);
  if(phpClass == null) {
    return;
  }
  for(DoctrineModelField field: EntityHelper.getModelFields(phpClass)) {
    if(field.getRelation() != null) {
      completionResultSet.addElement(new DoctrineModelFieldLookupElement(field));
    }
  }
}

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

/**
 * @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#getYamlKeyValueAsString
 */
public void testGetYamlKeyValueAsString() {
  String[] strings = {
    "{ name: routing.loader, method: foo }",
    "{ name: routing.loader, method: 'foo' }",
    "{ name: routing.loader, method: \"foo\" }",
  };
  for (String s : strings) {
    assertEquals("foo", YamlHelper.getYamlKeyValueAsString(
      YamlPsiElementFactory.createFromText(getProject(), YAMLHashImpl.class, s),
      "method"
    ));
  }
}

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

String tagName = YamlHelper.getYamlKeyValueAsString(yamlHash, "name");
if(tagName != null) {
  visitor.visit(new YamlServiceTag(serviceId, tagName, yamlHash));

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

String className = YamlHelper.getYamlKeyValueAsString((YAMLCompoundValue) yamlCompoundValue, "targetEntity", false);
if(className == null) {
  return;

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