void (@NotNull FileTypeWithDescriptor newFtd, @NotNull Map<? super String, FileTypeWithDescriptor> names, @NotNull String getterName, @NotNull Function<? super FileType, String> nameExtractor) { FileType newFileType = newFtd.fileType; String name = nameExtractor.apply(newFileType); FileTypeWithDescriptor prevFtd = names.put(name, newFtd); if (prevFtd != null && (prevFtd.fileType instanceof AbstractFileType) == (newFileType instanceof AbstractFileType)) { // should be able to override AbstractFileType silently String error = "\n" + prevFtd + " (" + prevFtd.fileType.getClass() + ") and" + "\n" + newFtd + " (" + newFileType.getClass() + ")\n" + " both have the same ." + getterName + "(): '" + name + "'. " + "Please override either one's " + getterName + "() to something unique."; PluginDescriptor pluginToBlame = prevFtd.pluginDescriptor.isBundled() ? newFtd.pluginDescriptor : prevFtd.pluginDescriptor; if (prevFtd.pluginDescriptor.isBundled() || newFtd.pluginDescriptor.isBundled()) { // file type from the plugin conflicts with 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())); } } }