@Override
  public @NotNull Element getState() {
    Element state = new Element("state");

    List<String> ignoreFiles = new ArrayList<>(ignoredPatterns.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 fileTypeDescriptor: getAllFileTypeWithDescriptors()) {
      if (!(fileTypeDescriptor.fileType() instanceof AbstractFileType) || defaultTypes.contains(fileTypeDescriptor)) {
        notExternalizableFileTypes.add(fileTypeDescriptor);
      }
    }
    if (!notExternalizableFileTypes.isEmpty()) {
      notExternalizableFileTypes.sort(Comparator.comparing(it -> it.fileType().getName()));
      for (FileTypeWithDescriptor ftd : notExternalizableFileTypes) {
        writeExtensionsMap(extensionMap, ftd, true);
      }
    }

    // https://youtrack.jetbrains.com/issue/IDEA-138366
    removedMappingTracker.save(extensionMap);

    if (!unresolvedMappings.isEmpty()) {
      List<Map.Entry<FileNameMatcher, String>> entries = new ArrayList<>(unresolvedMappings.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 (!unresolvedHashBangs.isEmpty()) {
      List<Map.Entry<String, String>> entries = new ArrayList<>(unresolvedHashBangs.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;
  }
@Override
  public @NotNull Element getState()