void (@NotNull Collection<? super FileType> result) { // add all file types that can be handled by the IDE internal formatter (== have FormattingModelBuilder) FileTypeManager fileTypeManager = FileTypeManager.getInstance(); for (FileType fileType : fileTypeManager.getRegisteredFileTypes()) { if (fileType instanceof LanguageFileType && !fileTypeManager.getAssociations(fileType).isEmpty() && LanguageFormatting.INSTANCE.forLanguage(((LanguageFileType)fileType).getLanguage()) != null) { result.add(fileType); } } // Iterating only FormattingModelBuilders is not enough. Some file types may get formatted by // external formatter integrated in the IDE (like ShExternalFormatter). // // A good sign that IDE supports some file type formatting is that it has a Code Style page for this file type. The following code makes // sure that all file types that have their Code Style pages are included in the result set. // // The logic of iterating Code Style pages is similar to what's done in CodeStyleSchemesConfigurable.buildConfigurables() for (CodeStyleSettingsProvider provider : CodeStyleSettingsProvider.EXTENSION_POINT_NAME.getExtensionList()) { Language language = provider.getLanguage(); if (provider.hasSettingsPage() && language != null) { ContainerUtil.addIfNotNull(result, language.getAssociatedFileType()); } } for (LanguageCodeStyleSettingsProvider provider : LanguageCodeStyleSettingsProvider.getSettingsPagesProviders()) { ContainerUtil.addIfNotNull(result, provider.getLanguage().getAssociatedFileType()); } }