|
16 | 16 | import org.apache.commons.lang.StringUtils;
|
17 | 17 | import org.jetbrains.annotations.NotNull;
|
18 | 18 | import org.jetbrains.yaml.YAMLFileType;
|
19 |
| -import org.jetbrains.yaml.psi.YAMLFile; |
20 |
| -import org.jetbrains.yaml.psi.YAMLKeyValue; |
21 |
| -import org.jetbrains.yaml.psi.YAMLSequence; |
22 |
| -import org.jetbrains.yaml.psi.YAMLValue; |
| 19 | +import org.jetbrains.yaml.psi.*; |
| 20 | +import org.jetbrains.yaml.psi.impl.YAMLArrayImpl; |
23 | 21 |
|
24 | 22 | import java.util.Collections;
|
25 | 23 | import java.util.HashMap;
|
| 24 | +import java.util.List; |
26 | 25 | import java.util.Map;
|
27 | 26 |
|
28 | 27 | /**
|
@@ -101,20 +100,54 @@ private static Map<String, Integer> getIdUsages(@NotNull YAMLFile yamlFile) {
|
101 | 100 | }
|
102 | 101 |
|
103 | 102 | YAMLKeyValue arguments = YamlHelper.getYamlKeyValue(yamlKeyValue, "arguments");
|
104 |
| - if(arguments == null) { |
105 |
| - continue; |
106 |
| - } |
107 |
| - |
108 |
| - YAMLValue value = arguments.getValue(); |
109 |
| - if(!(value instanceof YAMLSequence)) { |
110 |
| - continue; |
| 103 | + if(arguments != null) { |
| 104 | + YAMLValue value = arguments.getValue(); |
| 105 | + if(value instanceof YAMLSequence) { |
| 106 | + for (String id : YamlHelper.getYamlArrayValuesAsList((YAMLSequence) value)) { |
| 107 | + String idClean = YamlHelper.trimSpecialSyntaxServiceName(id); |
| 108 | + if(StringUtils.isNotBlank(idClean)) { |
| 109 | + services.putIfAbsent(idClean, 0); |
| 110 | + services.put(idClean, services.get(idClean) + 1); |
| 111 | + } |
| 112 | + } |
| 113 | + } |
111 | 114 | }
|
112 | 115 |
|
113 |
| - for (String id : YamlHelper.getYamlArrayValuesAsList((YAMLSequence) value)) { |
114 |
| - String idClean = YamlHelper.trimSpecialSyntaxServiceName(id); |
115 |
| - if(StringUtils.isNotBlank(idClean)) { |
116 |
| - services.putIfAbsent(idClean, 0); |
117 |
| - services.put(idClean, services.get(idClean) + 1); |
| 116 | + // calls: |
| 117 | + // - [foo, [@bar, @bar]] |
| 118 | + YAMLKeyValue calls = YamlHelper.getYamlKeyValue(yamlKeyValue, "calls"); |
| 119 | + if(calls != null) { |
| 120 | + |
| 121 | + for (YAMLPsiElement yamlPsiElement : calls.getYAMLElements()) { |
| 122 | + if(yamlPsiElement instanceof YAMLSequence) { |
| 123 | + for (YAMLSequenceItem yamlSequenceItem : ((YAMLSequence) yamlPsiElement).getItems()) { |
| 124 | + YAMLValue value = yamlSequenceItem.getValue(); |
| 125 | + if(value instanceof YAMLSequence) { |
| 126 | + List<YAMLSequenceItem> items = ((YAMLSequence) value).getItems(); |
| 127 | + if(items.size() > 1) { |
| 128 | + // [foo, [@bar, @bar2]] |
| 129 | + |
| 130 | + YAMLValue value1 = items.get(1).getValue(); |
| 131 | + if(value1 instanceof YAMLSequence) { |
| 132 | + // [@bar, @bar2] |
| 133 | + |
| 134 | + for (YAMLSequenceItem sequenceItem : ((YAMLArrayImpl) value1).getItems()) { |
| 135 | + YAMLValue value2 = sequenceItem.getValue(); |
| 136 | + if(value2 instanceof YAMLScalar) { |
| 137 | + String textValue = ((YAMLScalar) value2).getTextValue(); |
| 138 | + |
| 139 | + String idClean = YamlHelper.trimSpecialSyntaxServiceName(textValue); |
| 140 | + if(StringUtils.isNotBlank(idClean)) { |
| 141 | + services.putIfAbsent(idClean, 0); |
| 142 | + services.put(idClean, services.get(idClean) + 1); |
| 143 | + } |
| 144 | + } |
| 145 | + } |
| 146 | + } |
| 147 | + } |
| 148 | + } |
| 149 | + } |
| 150 | + } |
118 | 151 | }
|
119 | 152 | }
|
120 | 153 | }
|
|
0 commit comments