use of com.intellij.openapi.components.CompositePathMacroFilter in project intellij-community by JetBrains.
the class FileStorageCoreUtil method load.
@NotNull
public static TreeMap<String, Element> load(@NotNull Element rootElement, @Nullable PathMacroSubstitutor pathMacroSubstitutor, boolean intern) {
if (pathMacroSubstitutor != null) {
pathMacroSubstitutor.expandPaths(rootElement);
}
StringInterner interner = intern ? new StringInterner() : null;
List<Element> children = rootElement.getChildren(COMPONENT);
if (children.isEmpty() && rootElement.getName().equals(COMPONENT) && rootElement.getAttributeValue(NAME) != null) {
// exclusive component data
// singleton must be not used here - later we modify list
children = new SmartList<>(rootElement);
}
CompositePathMacroFilter filter = null;
TreeMap<String, Element> map = new TreeMap<>();
for (Iterator<Element> iterator = children.iterator(); iterator.hasNext(); ) {
Element element = iterator.next();
String name = getComponentNameIfValid(element);
if (name == null || !(element.getAttributes().size() > 1 || !element.getChildren().isEmpty())) {
continue;
}
// so, PathMacroFilter can easily find component name (null parent)
iterator.remove();
if (interner != null) {
JDOMUtil.internElement(element, interner);
}
map.put(name, element);
if (pathMacroSubstitutor instanceof TrackingPathMacroSubstitutor) {
if (filter == null) {
filter = new CompositePathMacroFilter(PathMacrosCollector.MACRO_FILTER_EXTENSION_POINT_NAME.getExtensions());
}
((TrackingPathMacroSubstitutor) pathMacroSubstitutor).addUnknownMacros(name, PathMacrosCollector.getMacroNames(element, filter, PathMacros.getInstance()));
}
// remove only after "getMacroNames" - some PathMacroFilter requires element name attribute
element.removeAttribute(NAME);
}
return map;
}
Aggregations