@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()); }
YAMLKeyValue aClass = childOfType.getKeyValueByKey("class"); if(aClass != null) { return new ServiceYamlContainer(yamlServiceKeyValue, childOfType.getKeyValueByKey("arguments"), serviceClass);
@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; }
/** * 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; }
/** * 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[]{}); }
YAMLKeyValue classKeyValue = parentMapping.getKeyValueByKey("class"); if (classKeyValue != null) { String valueText = classKeyValue.getValueText();
YAMLKeyValue roles = ((YAMLMapping) value1).getKeyValueByKey("roles"); if(roles == null) { continue;