void (@NotNull FileType fileType, @NotNull String extension, @NotNull Disposable parentDisposable) { FileTypeManager fileTypeManager = FileTypeManager.getInstance(); if (!fileType.equals(fileTypeManager.getFileTypeByExtension(extension))) { WriteAction.runAndWait(() -> fileTypeManager.associateExtension(fileType, extension)); Disposer.register(parentDisposable, ()->WriteAction.runAndWait(() -> fileTypeManager.removeAssociatedExtension(fileType, extension))); } }