void (@NotNull Element extensionMap, @NotNull FileTypeWithDescriptor ftd, boolean specifyTypeName) { FileType type = ftd.fileType; List<FileNameMatcher> associations = myPatternsTable.getAssociations(ftd); Set<FileNameMatcher> defaultAssociations = new HashSet<>(myInitialAssociations.getAssociations(type)); for (FileNameMatcher matcher : associations) { boolean isDefaultAssociationContains = defaultAssociations.remove(matcher); if (!isDefaultAssociationContains && shouldSave(type)) { Element content = AbstractFileType.writeMapping(type.getName(), matcher, specifyTypeName); if (content != null) { extensionMap.addContent(content); } } } List<String> readOnlyHashBangs = myInitialAssociations.getHashBangPatterns(type); List<String> hashBangPatterns = myPatternsTable.getHashBangPatterns(ftd); hashBangPatterns.sort(Comparator.naturalOrder()); for (String hashBangPattern : hashBangPatterns) { if (!readOnlyHashBangs.contains(hashBangPattern)) { writeHashBang(extensionMap, hashBangPattern, type.getName()); } } List<FileNameMatcher> removedMappings = myRemovedMappingTracker.getMappingsForFileType(type.getName()); // do not store removed mappings which are going to be stored anyway via RemovedMappingTracker.save() defaultAssociations.removeIf(matcher -> removedMappings.contains(matcher)); myRemovedMappingTracker.saveRemovedMappingsForFileType(extensionMap, type.getName(), defaultAssociations, specifyTypeName); }