Element () { Element element = new Element("state"); List<Map.Entry<VirtualFile, FileHighlightingSetting[]>> entries = new ArrayList<>(myHighlightSettings.entrySet()); entries.sort(Comparator.comparing(entry -> entry.getKey().getPath())); for (Map.Entry<VirtualFile, FileHighlightingSetting[]> entry : entries) { Element child = new Element(SETTING_TAG); VirtualFile vFile = entry.getKey(); if (!vFile.isValid()) continue; child.setAttribute(FILE_ATT, vFile.getUrl()); for (int i = 0; i < entry.getValue().length; i++) { FileHighlightingSetting fileHighlightingSetting = entry.getValue()[i]; child.setAttribute(ROOT_ATT_PREFIX + i, fileHighlightingSetting.toString()); } element.addContent(child); } return element; }