/** * FOO: * - foobar * * FOO: [foobar] */ @NotNull static public Collection<YAMLSequenceItem> getSequenceItems(@NotNull YAMLKeyValue yamlKeyValue) { PsiElement yamlSequence = yamlKeyValue.getLastChild(); if(yamlSequence instanceof YAMLSequence) { return ((YAMLSequence) yamlSequence).getItems(); } return Collections.emptyList(); }
/** * Simplify getting of array psi elements in array or sequence context * * arguments: [@foo] * arguments: * - @foo * * TODO: can be handled nice know because on new yaml plugin */ @Nullable public static List<PsiElement> getYamlArrayOnSequenceOrArrayElements(@NotNull YAMLCompoundValue yamlCompoundValue) { if (yamlCompoundValue instanceof YAMLSequence) { return new ArrayList<>(((YAMLSequence) yamlCompoundValue).getItems()); } if (yamlCompoundValue instanceof YAMLMapping) { return new ArrayList<>(((YAMLMapping) yamlCompoundValue).getKeyValues()); } return null; }
/** * [ROLE_USER, FEATURE_ALPHA, ROLE_ALLOWED_TO_SWITCH] */ @NotNull static public Collection<String> getYamlArrayValuesAsList(@NotNull YAMLSequence yamlArray) { Collection<String> keys = new ArrayList<>(); for (YAMLSequenceItem yamlSequenceItem : yamlArray.getItems()) { YAMLValue value = yamlSequenceItem.getValue(); if(!(value instanceof YAMLScalar)) { continue; } String textValue = ((YAMLScalar) value).getTextValue(); if(StringUtils.isNotBlank(textValue)) { keys.add(textValue); } } return keys; }
for (YAMLSequenceItem yamlSequenceItem : ((YAMLSequence) tagsCompound).getItems()) {
for (YAMLSequenceItem yamlSequenceItem : ((YAMLSequence) yamlPsiElement).getItems()) { YAMLValue value = yamlSequenceItem.getValue(); if(value instanceof YAMLSequence) { List<YAMLSequenceItem> callItem = ((YAMLSequence) value).getItems(); if(callItem.size() > 1) { for (YAMLSequenceItem methodArgument : ((YAMLSequence) methodArguments).getItems()) { YAMLValue value2 = methodArgument.getValue();
for(YAMLSequenceItem yamlSequenceItem: ((YAMLSequence) tagsValue).getItems()) { final YAMLValue itemValue = yamlSequenceItem.getValue();
if(callYamlSeq instanceof YAMLSequence) { List<YAMLSequenceItem> methodParameter = yamlCallArray.getItems(); if(methodParameter.size() > 1) { YAMLValue methodNameElement = methodParameter.get(0).getValue();