Element () { Element state = new Element("state"); List<String> ignoreFiles = new ArrayList<>(myIgnoredPatterns.getIgnoreMasks()); ignoreFiles.sort(null); if (!isEqualToDefaultIgnoreMasks(ignoreFiles)) { // empty means empty list - we need to distinguish null and empty to apply or not to apply default value state.addContent(new Element(ELEMENT_IGNORE_FILES).setAttribute(ATTRIBUTE_LIST, String.join(";", ignoreFiles))); } Element extensionMap = new Element(ELEMENT_EXTENSION_MAP); List<FileTypeWithDescriptor> notExternalizableFileTypes = new ArrayList<>(); for (FileTypeWithDescriptor ftd: getAllFileTypeWithDescriptors()) { if (!(ftd.fileType instanceof AbstractFileType) || myDefaultTypes.contains(ftd)) { notExternalizableFileTypes.add(ftd); } } if (!notExternalizableFileTypes.isEmpty()) { notExternalizableFileTypes.sort(Comparator.comparing(ftd -> ftd.fileType.getName())); for (FileTypeWithDescriptor ftd : notExternalizableFileTypes) { writeExtensionsMap(extensionMap, ftd, true); } } // https://youtrack.jetbrains.com/issue/IDEA-138366 myRemovedMappingTracker.save(extensionMap); if (!myUnresolvedMappings.isEmpty()) { List<Map.Entry<FileNameMatcher, String>> entries = new ArrayList<>(myUnresolvedMappings.entrySet()); entries.sort(Comparator.comparing(e -> e.getKey().getPresentableString())); for (Map.Entry<FileNameMatcher, String> entry : entries) { FileNameMatcher fileNameMatcher = entry.getKey(); String typeName = entry.getValue(); Element content = AbstractFileType.writeMapping(typeName, fileNameMatcher, true); if (content != null) { extensionMap.addContent(content); } } } if (!myUnresolvedHashBangs.isEmpty()) { List<Map.Entry<String, String>> entries = new ArrayList<>(myUnresolvedHashBangs.entrySet()); entries.sort(Map.Entry.comparingByKey()); for (Map.Entry<String, String> entry : entries) { String pattern = entry.getKey(); String typeName = entry.getValue(); writeHashBang(extensionMap, pattern, typeName); } } if (!extensionMap.getChildren().isEmpty()) { state.addContent(extensionMap); } if (!state.getChildren().isEmpty()) { state.setAttribute(ATTRIBUTE_VERSION, String.valueOf(VERSION)); } return state; }