gpt4 book ai didi

org.jetbrains.yaml.psi.YAMLMapping.getKeyValueByKey()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 13:16:33 29 4
gpt4 key购买 nike

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

YAMLMapping.getKeyValueByKey介绍

暂无

代码示例

代码示例来源:origin: zalando/intellij-swagger

@Override
public List<PsiElement> getTags(final PsiFile psiFile) {
 return getRootChildrenOfType(psiFile, YAMLKeyValue.class)
   .stream()
   .filter(yamlKeyValue -> "tags".equals(yamlKeyValue.getName()))
   .map(YAMLKeyValue::getValue)
   .map(YAMLPsiElement::getYAMLElements)
   .flatMap(Collection::stream)
   .filter(el -> el instanceof YAMLSequenceItem)
   .map(YAMLSequenceItem.class::cast)
   .map(YAMLSequenceItem::getYAMLElements)
   .flatMap(Collection::stream)
   .filter(el -> el instanceof YAMLMapping)
   .map(YAMLMapping.class::cast)
   .map(yamlMapping -> yamlMapping.getKeyValueByKey("name"))
   .map(YAMLKeyValue::getValue)
   .filter(Objects::nonNull)
   .collect(Collectors.toList());
}

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

YAMLKeyValue aClass = childOfType.getKeyValueByKey("class");
if(aClass != null) {
return new ServiceYamlContainer(yamlServiceKeyValue, childOfType.getKeyValueByKey("arguments"), serviceClass);

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

@Nullable
public static YAMLKeyValue getYamlKeyValue(@Nullable PsiElement yamlCompoundValue, String keyName, boolean ignoreCase) {
  if (!(yamlCompoundValue instanceof YAMLMapping)) {
    return null;
  }
  if (!ignoreCase) {
    return ((YAMLMapping) yamlCompoundValue).getKeyValueByKey(keyName);
  }
  
  YAMLKeyValue classKeyValue;
  classKeyValue = PsiElementUtils.getChildrenOfType(yamlCompoundValue, PlatformPatterns.psiElement(YAMLKeyValue.class).withName(PlatformPatterns.string().oneOfIgnoreCase(keyName)));
  if(classKeyValue == null) {
    return null;
  }
  return classKeyValue;
}

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

/**
 * Symfony 3.3: "class" is optional; use service name for its it
 *
 * Foo\Bar:
 *  arguments: ~
 */
@Nullable
public static String getServiceClassFromServiceMapping(@NotNull YAMLMapping yamlMapping) {
  YAMLKeyValue classKeyValue = yamlMapping.getKeyValueByKey("class");
  // Symfony 3.3: "class" is optional; use service id for class
  // Foo\Bar:
  //   arguments: ~
  if(classKeyValue != null) {
    return classKeyValue.getValueText();
  }
  PsiElement parent = yamlMapping.getParent();
  if(parent instanceof YAMLKeyValue) {
    String keyText = ((YAMLKeyValue) parent).getKeyText();
    if(YamlHelper.isClassServiceId(keyText)) {
      return keyText;
    }
  }
  return null;
}

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

/**
 * Find last known KeyValue of key path, so that we can merge new incoming keys
 */
@NotNull
private static Pair<YAMLKeyValue, String[]> findLastKnownKeyInFile(@NotNull YAMLFile file, @NotNull String... keys) {
  YAMLKeyValue last = null;
  YAMLMapping mapping = ObjectUtils.tryCast(file.getDocuments().get(0).getTopLevelValue(), YAMLMapping.class);
  for (int i = 0; i < keys.length; i++) {
    String s = keys[i];
    if (mapping == null) {
      return Pair.create(last, Arrays.copyOfRange(keys, i, keys.length));
    }
    YAMLKeyValue keyValue = mapping.getKeyValueByKey(s);
    if (keyValue == null) {
      return Pair.create(last, Arrays.copyOfRange(keys, i, keys.length));
    }
    last = keyValue;
    mapping = ObjectUtils.tryCast(keyValue.getValue(), YAMLMapping.class);
  }
  return Pair.create(last, new String[]{});
}

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

YAMLKeyValue classKeyValue = parentMapping.getKeyValueByKey("class");
if (classKeyValue != null) {
  String valueText = classKeyValue.getValueText();

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

YAMLKeyValue roles = ((YAMLMapping) value1).getKeyValueByKey("roles");
if(roles == null) {
  continue;

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