private static void checkUnique(@NotNull FileTypeWithDescriptor newFileTypeWithDescriptor,
                                  @NotNull Map<? super String, FileTypeWithDescriptor> names,
                                  @NotNull String getterName,
                                  @NotNull Function<? super FileType, String> nameExtractor) {
    FileType newFileType = newFileTypeWithDescriptor.fileType();
    String name = nameExtractor.apply(newFileType);
    FileTypeWithDescriptor prevFileTypeWithDescriptor = names.put(name, newFileTypeWithDescriptor);
    if (prevFileTypeWithDescriptor != null && (prevFileTypeWithDescriptor.fileType() instanceof AbstractFileType) == (newFileType instanceof AbstractFileType)) {
      // should be able to override AbstractFileType silently
      String error = "\n" + prevFileTypeWithDescriptor + " (" + prevFileTypeWithDescriptor.fileType().getClass() + ") and" +
                     "\n" + newFileTypeWithDescriptor + " (" + newFileType.getClass() + ")\n" +
                     " both have the same ." + getterName + "(): '" + name + "'. " +
                     "Please override either one's " + getterName + "() to something unique.";
      PluginDescriptor pluginToBlame = prevFileTypeWithDescriptor.pluginDescriptor().isBundled() ? newFileTypeWithDescriptor.pluginDescriptor()
                                                                                                 : prevFileTypeWithDescriptor.pluginDescriptor();
      if (prevFileTypeWithDescriptor.pluginDescriptor().isBundled() || newFileTypeWithDescriptor.pluginDescriptor().isBundled()) {
        // file type from the plugin conflicts with a bundled file type
        LOG.error(new PluginException(error, pluginToBlame.getPluginId()));
      }
      else {
        // two plugins conflict between themselves (or one plugin has multiple personality disordered file types); we wash our hands in this case
        LOG.warn(new PluginException(error, pluginToBlame.getPluginId()));
      }
    }
  }
private static void checkUnique(@NotNull FileTypeWithDescriptor newFileTypeWithDescriptor,
                                  @NotNull Map<? super String, FileTypeWithDescriptor> names,
                                  @NotNull String getterName,
                                  @NotNull Function<? super FileType, String> nameExtractor)