Skip to content

Commit 329ff9e

Browse files
committed
support yaml translation keys on new yaml plugin version #626
1 parent bf56681 commit 329ff9e

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/fr/adrienbrault/idea/symfony2plugin/translation/collector/YamlTranslationVistor.java

+6-10
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
import com.intellij.psi.PsiElement;
55
import com.intellij.psi.util.PsiTreeUtil;
6+
import fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper;
67
import org.apache.commons.lang.StringUtils;
8+
import org.jetbrains.yaml.YAMLUtil;
79
import org.jetbrains.yaml.psi.*;
810

911
import java.util.ArrayList;
@@ -13,14 +15,7 @@
1315
public class YamlTranslationVistor {
1416

1517
public static void collectFileTranslations(YAMLFile yamlFile, YamlTranslationCollector translationCollector) {
16-
List<YAMLDocument> documents = yamlFile.getDocuments();
17-
18-
if(documents.size() < 1) {
19-
return;
20-
}
21-
22-
Collection<YAMLKeyValue> yamlKeyValues = PsiTreeUtil.getChildrenOfTypeAsList(documents.get(0), YAMLKeyValue.class);
23-
for(YAMLKeyValue yamlKeyValue: yamlKeyValues) {
18+
for(YAMLKeyValue yamlKeyValue: YamlHelper.getTopLevelKeyValues(yamlFile)) {
2419
collectItems(yamlKeyValue, translationCollector);
2520
}
2621

@@ -53,15 +48,16 @@ private static boolean collectItems(List<String> levels, YAMLKeyValue yamlKeyVal
5348
return true;
5449
}
5550

51+
// @TODO: use features of new yaml integration
5652
// yaml key-value provide main psielement in last child element
5753
// depending of what we get here we have another key-value inside, multiline or string value
58-
if(childElements.size() == 1) {
54+
if(childElements.size() == 1 && childElements.get(0) instanceof YAMLMapping) {
5955

6056

6157
PsiElement lastChildElement = childElements.get(0);
6258

6359
// catch next level keys
64-
if(lastChildElement instanceof YAMLCompoundValue) {
60+
if(lastChildElement instanceof YAMLMapping) {
6561

6662
// use copy of current level and pipe to children call
6763
ArrayList<String> copyLevels = new ArrayList<String>(levels);

0 commit comments

Comments
 (0)