List<FileTypeInfo> () { final List<LanguageFileType> types = new ArrayList<>(); for (LanguageFileType fileType : StructuralSearchUtil.getSuitableFileTypes()) { if (StructuralSearchUtil.getProfileByFileType(fileType) != null) { types.add(fileType); } } types.sort((o1, o2) -> o1.getDescription().compareToIgnoreCase(o2.getDescription())); final List<FileTypeInfo> infos = new ArrayList<>(); for (LanguageFileType fileType : types) { final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByFileType(fileType); assert profile != null; final Language language = fileType.getLanguage(); final List<PatternContext> patternContexts = new ArrayList<>(profile.getPatternContexts()); if (!patternContexts.isEmpty()) { infos.add(new FileTypeInfo(fileType, language, patternContexts.get(0), false)); for (int i = 1; i < patternContexts.size(); i++) { infos.add(new FileTypeInfo(fileType, language, patternContexts.get(i), true)); } continue; // proceed with the next file type } infos.add(new FileTypeInfo(fileType, language, null, false)); final List<Language> dialects = new ArrayList<>(language.getDialects()); dialects.sort(Comparator.comparing(Language::getDisplayName)); for (Language dialect : dialects) { if (profile.isMyLanguage(dialect)) { infos.add(new FileTypeInfo(fileType, dialect, null, true)); } } } return infos; }