ListPopup (@NotNull Project project, @NotNull PsiFile file, @NotNull Editor editor) { DefaultActionGroup languageGroup = new DefaultActionGroup(); Set<Language> preferredLanguages = getPreferredLanguages(file, editor.getCaretModel().getOffset()); getSupportedLanguages().stream() .sorted((l1, l2) -> { if (preferredLanguages == null) return 0; return (preferredLanguages.contains(l2) ? 1 : 0) - (preferredLanguages.contains(l1) ? 1 : 0); }) .forEach( language -> { languageGroup.add( LightEditActionFactory .create(language.getDisplayName(), event -> generateProperties(project, editor, language))); } ); return JBPopupFactory.getInstance().createActionGroupPopup( EditorConfigBundle.message("popup.title.choose.language"), languageGroup, DataManager.getInstance().getDataContext(editor.getComponent()), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false); }