public Set<String> getDifference(final StorageData storageData, PathMacroSubstitutor substitutor) { Set<String> bothStates = new HashSet<String>(myComponentStates.keySet()); bothStates.retainAll(storageData.myComponentStates.keySet()); Set<String> diffs = new HashSet<String>(); diffs.addAll(storageData.myComponentStates.keySet()); diffs.addAll(myComponentStates.keySet()); diffs.removeAll(bothStates); for (String componentName : bothStates) { final Element e1 = myComponentStates.get(componentName); final Element e2 = storageData.myComponentStates.get(componentName); // some configurations want to collapse path elements in writeExternal so make sure paths are expanded if (substitutor != null) { substitutor.expandPaths(e2); } if (!JDOMUtil.areElementsEqual(e1, e2)) { diffs.add(componentName); } } return diffs; }
@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); TreeMap<String, Element> map = new TreeMap<String, Element>(); for (Element element : children) { String name = getComponentNameIfValid(element); if (name == null || !(element.getAttributes().size() > 1 || !element.getChildren().isEmpty())) { continue; } if (interner != null) { JDOMUtil.internElement(element, interner); } map.put(name, element); if (pathMacroSubstitutor instanceof TrackingPathMacroSubstitutor) { ((TrackingPathMacroSubstitutor)pathMacroSubstitutor).addUnknownMacros(name, PathMacrosCollector.getMacroNames(element)); } // remove only after "getMacroNames" - some PathMacroFilter requires element name attribute element.removeAttribute(NAME); } return map; }
public void load(@Nonnull Element rootElement, @Nullable PathMacroSubstitutor pathMacroSubstitutor, boolean intern) { if (pathMacroSubstitutor != null) { pathMacroSubstitutor.expandPaths(rootElement); } StringInterner interner = intern ? new StringInterner() : null; for (Iterator<Element> iterator = rootElement.getChildren(COMPONENT).iterator(); iterator.hasNext(); ) { Element element = iterator.next(); String name = getComponentNameIfValid(element); if (name == null || !(element.getAttributes().size() > 1 || !element.getChildren().isEmpty())) { continue; } iterator.remove(); if (interner != null) { JDOMUtil.internStringsInElement(element, interner); } myStates.put(name, element); if (pathMacroSubstitutor instanceof TrackingPathMacroSubstitutor) { ((TrackingPathMacroSubstitutor)pathMacroSubstitutor).addUnknownMacros(name, PathMacrosService.getInstance().getMacroNames(element)); } // remove only after "getMacroNames" - some PathMacroFilter requires element name attribute element.removeAttribute(NAME); } }
public Set<String> getChangedComponentNames(@Nonnull StorageData newStorageData, @Nullable PathMacroSubstitutor substitutor) { Set<String> bothStates = new SmartHashSet<String>(myStates.keys()); bothStates.retainAll(newStorageData.myStates.keys()); Set<String> diffs = new SmartHashSet<String>(); diffs.addAll(newStorageData.myStates.keys()); diffs.addAll(myStates.keys()); diffs.removeAll(bothStates); for (String componentName : bothStates) { myStates.compare(componentName, newStorageData.myStates, diffs); } return diffs; }