use of com.intellij.lang.properties.editor.ResourceBundlePropertyStructureViewElement in project intellij-community by JetBrains.
the class PropertiesPrefixGroup method getChildren.
@NotNull
public Collection<TreeElement> getChildren() {
Collection<TreeElement> result = new ArrayList<>();
List<String> prefixWords = StringUtil.split(myPrefix, mySeparator);
for (TreeElement treeElement : myProperties) {
if (!(treeElement instanceof StructureViewTreeElement)) {
continue;
}
Object value = ((StructureViewTreeElement) treeElement).getValue();
if (!(value instanceof IProperty)) {
continue;
}
final String key = ((IProperty) value).getUnescapedKey();
if (key == null) {
continue;
}
boolean startsWith;
if (!key.equals(myPrefix)) {
List<String> keyWords = StringUtil.split(key, mySeparator);
startsWith = prefixWords.size() < keyWords.size();
if (startsWith) {
for (int i = 0; i < prefixWords.size(); i++) {
String prefixWord = prefixWords.get(i);
String keyWord = keyWords.get(i);
if (!Comparing.strEqual(keyWord, prefixWord)) {
startsWith = false;
break;
}
}
}
} else {
startsWith = true;
}
if (startsWith) {
result.add(treeElement);
String presentableName = key.substring(myPrefix.length());
presentableName = StringUtil.trimStart(presentableName, mySeparator);
if (treeElement instanceof PropertiesStructureViewElement) {
((PropertiesStructureViewElement) treeElement).setPresentableName(presentableName);
}
if (treeElement instanceof ResourceBundlePropertyStructureViewElement) {
((ResourceBundlePropertyStructureViewElement) treeElement).setPresentableName(presentableName);
}
}
}
return result;
}
Aggregations