gpt4 book ai didi

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

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

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

YAMLKeyValue.getKeyText介绍

暂无

代码示例

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

@Override
  public boolean accepts(@NotNull YAMLKeyValue yamlKeyValue, ProcessingContext processingContext) {
    return this.keyText.equals(yamlKeyValue.getKeyText());
  }
}

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

@Override
  public boolean accepts(@NotNull YAMLKeyValue yamlKeyValue, ProcessingContext context) {
    return "_defaults".equals(yamlKeyValue.getKeyText());
  }
}));

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

@Override
  public boolean accepts(@NotNull YAMLKeyValue yamlKeyValue, ProcessingContext context) {
    return "bind".equals(yamlKeyValue.getKeyText());
  }
}).withParent(defaultsKey));

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

@Nullable
  @Override
  protected String getElementText(@NotNull PsiElement element) {
    PsiElement parent = element.getParent();
    if(!(parent instanceof YAMLKeyValue)) {
      return null;
    }
    String keyText = ((YAMLKeyValue) parent).getKeyText();
    if(StringUtils.isBlank(keyText)) {
      return null;
    }
    return keyText;
  }
}

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

@Nullable
  private PsiElement getYamlKeyPath(@NotNull PsiFile psiFile, final @NotNull String findServiceName, @NotNull String rootKey) {
    final Collection<PsiElement> psiElements = new ArrayList<>();
    // @TODO: support case insensitive
    visitQualifiedKeyValuesInFile((YAMLFile) psiFile, rootKey, yamlKeyValue -> {
      if(findServiceName.equalsIgnoreCase(yamlKeyValue.getKeyText())) {
        psiElements.add(yamlKeyValue);
      }
    });
    if(psiElements.size() == 0) {
      return null;
    }
    // @TODO: provide support for multiple targets
    return psiElements.iterator().next();
  }
}

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

@NotNull
private Collection<PsiElement> visitConfigKey(@NotNull PsiElement psiElement) {
  PsiElement parent = psiElement.getParent();
  if(!(parent instanceof YAMLKeyValue)) {
    return Collections.emptyList();
  }
  String keyText = ((YAMLKeyValue) parent).getKeyText();
  if(StringUtils.isBlank(keyText)) {
    return Collections.emptyList();
  }
  return ConfigUtil.getTreeSignatureTargets(psiElement.getProject(), keyText);
}

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

@Override
  public boolean value(PsiElement psiElement) {
    return psiElement instanceof YAMLKeyValue && ((YAMLKeyValue) psiElement).getKeyText().equals(this.key);
  }
}

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

@Override
  public boolean value(PsiElement psiElement) {
    return psiElement instanceof YAMLKeyValue && ((YAMLKeyValue) psiElement).getKeyText().equals("name");
  }
}));

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

@Override
  public boolean value(YAMLKeyValue yamlKeyValue) {
    return key.equals(yamlKeyValue.getKeyText());
  }
}

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

/**
 * services:
 *   My<caret>Class: ~
 */
private Collection<PsiElement> getClassesForServiceKey(@NotNull PsiElement psiElement) {
  PsiElement parent = psiElement.getParent();
  if(parent instanceof YAMLKeyValue) {
    String valueText = ((YAMLKeyValue) parent).getKeyText();
    if(StringUtils.isNotBlank(valueText)) {
      return new ArrayList<>(PhpElementsUtil.getClassesInterface(psiElement.getProject(), valueText));
    }
  }
  return Collections.emptyList();
}

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

private void registerYmlRoutePatternProblem(@NotNull ProblemsHolder holder, @NotNull YAMLKeyValue element) {
  String s = PsiElementUtils.trimQuote(element.getKeyText());
  if(("factory_class".equals(s) || "factory_method".equals(s) || "factory_service".equals(s)) && YamlElementPatternHelper.getInsideServiceKeyPattern().accepts(element)) {
    // services:
    //   foo:
    //      factory_*:
    registerProblem(holder, element.getKey());
  }
}

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

@Override
  public boolean accepts(@NotNull YAMLKeyValue yamlKeyValue, ProcessingContext processingContext) {
    return yamlKeyValue.getKeyText().equals("foo");
  }
})));

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

@Override
  public boolean accepts(@NotNull YAMLKeyValue yamlKeyValue, ProcessingContext processingContext) {
    return yamlKeyValue.getKeyText().equals("Service\\YamlBar");
  }
})));

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

private void registerYmlRoutePatternProblem(@NotNull ProblemsHolder holder, @NotNull YAMLKeyValue element) {
  String s = PsiElementUtils.trimQuote(element.getKeyText());
  if("pattern".equals(s) && YamlHelper.isRoutingFile(element.getContainingFile())) {
    // pattern: foo
    holder.registerProblem(element.getKey(), "Pattern is deprecated; use path instead", ProblemHighlightType.LIKE_DEPRECATED);
  } else if(("_method".equals(s) || "_scheme".equals(s)) && YamlHelper.isRoutingFile(element.getContainingFile())) {
    // requirements: { _method: 'foo', '_scheme': 'foo' }
    YAMLKeyValue parentOfType = PsiTreeUtil.getParentOfType(element, YAMLKeyValue.class);
    if(parentOfType != null && "requirements".equals(parentOfType.getKeyText())) {
      holder.registerProblem(element.getKey(), String.format("The '%s' requirement is deprecated", s), ProblemHighlightType.LIKE_DEPRECATED);
    }
  }
}

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

public static void visitFile(@NotNull YAMLFile psiFile, @NotNull Consumer<ServiceConsumer> consumer) {
  ServiceFileDefaults defaults = null;
  for (YAMLKeyValue keyValue : YamlHelper.getQualifiedKeyValuesInFile(psiFile, "services")) {
    if(defaults == null) {
      defaults = createDefaults(psiFile);
    }
    String serviceId = keyValue.getKeyText();
    if(StringUtils.isBlank(serviceId) || "_defaults".equals(serviceId)) {
      continue;
    }
    consumer.consume(new ServiceConsumer(keyValue, serviceId, new YamlKeyValueAttributeValue(keyValue), defaults));
  }
}

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

@Nullable
public static PsiElement insertKeyIntoFile(final @NotNull YAMLFile yamlFile, final @NotNull YAMLKeyValue yamlKeyValue, @NotNull String... keys) {
  String keyText = yamlKeyValue.getKeyText();
  return insertKeyIntoFile(yamlFile, (yamlMapping, chainedKey) -> {
    String text = yamlKeyValue.getText();
    final String previousIndent = StringUtil.repeatSymbol(' ', YAMLUtil.getIndentInThisLine(yamlMapping));
    // split content of array value object;
    // drop first item as getValueText() removes our key indent
    String[] remove = (String[]) ArrayUtils.remove(text.split("\\r?\\n"), 0);
    List<String> map = ContainerUtil.map(remove, s -> previousIndent + s);
    return "\n" + StringUtils.strip(StringUtils.join(map, "\n"), "\n");
  }, (String[]) ArrayUtils.add(keys, keyText));
}

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

private void visitRootElements(@NotNull Collection<LineMarkerInfo> result, @NotNull PsiElement psiElement, @NotNull LazyConfigTreeSignatures function) {
  PsiElement parent = psiElement.getParent();
  if(!(parent instanceof YAMLKeyValue)) {
    return;
  }
  String keyText = ((YAMLKeyValue) parent).getKeyText();
  Map<String, Collection<String>> treeSignatures = function.value();
  if(!treeSignatures.containsKey(keyText)) {
    return;
  }
  NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(Symfony2Icons.SYMFONY_LINE_MARKER)
    .setTargets(new MyClassIdLazyValue(psiElement.getProject(), treeSignatures.get(keyText), keyText))
    .setTooltipText("Navigate to configuration");
  result.add(builder.createLineMarkerInfo(psiElement));
}

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

@Override
public void visitElement(final PsiElement element) {
 if (element instanceof YAMLKeyValue) {
  final YAMLKeyValue yamlKeyValue = (YAMLKeyValue) element;
  if (OpenApiConstants.REF_KEY.equals(yamlKeyValue.getKeyText())) {
   final String refValue = StringUtils.removeAllQuotes(yamlKeyValue.getValueText());
   if (isYamlFile(refValue)) {
    result.add(
      extractFileNameFromFileRefValue(refValue)
        + DELIMITER
        + getOpenApiFileTypeFromRefElement(yamlKeyValue.getValue(), refValue));
   }
  }
 }
 super.visitElement(element);
}

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

@Override
public void visitElement(final PsiElement element) {
 if (element instanceof YAMLKeyValue) {
  final YAMLKeyValue yamlKeyValue = (YAMLKeyValue) element;
  if (SwaggerConstants.REF_KEY.equals(yamlKeyValue.getKeyText())) {
   final String refValue = StringUtils.removeAllQuotes(yamlKeyValue.getValueText());
   if (isYamlFile(refValue)) {
    result.add(
      extractFileNameFromFileRefValue(refValue)
        + DELIMITER
        + getSwaggerFileType(yamlKeyValue.getValue(), refValue));
   }
  }
 }
 super.visitElement(element);
}

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

/**
 * @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#findServiceInContext
 */
public void testFindServiceInContext() {
  assertEquals("foo", YamlHelper.findServiceInContext(myFixture.configureByText(YAMLFileType.YML, "" +
    "services:\n" +
    "  foo:\n" +
    "    tags:\n" +
    "      - { name: fo<caret>o}\n"
  ).findElementAt(myFixture.getCaretOffset())).getKeyText());
  assertEquals("foo", YamlHelper.findServiceInContext(myFixture.configureByText(YAMLFileType.YML, "" +
    "services:\n" +
    "  foo:\n" +
    "    class: fo<caret>o"
  ).findElementAt(myFixture.getCaretOffset())).getKeyText());
}

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