void (@Nullable String lastUsed) { Object source = getSource(); ArrayList<Language> items = new ArrayList<>(); if (source instanceof LanguageFileType) { Language baseLang = ((LanguageFileType)source).getLanguage(); JBTreeTraverser.from(Language::getDialects).withRoot(baseLang) .preOrderDfsTraversal() .addAllTo(items); items.subList(1, items.size()).sort(LanguageUtil.LANGUAGE_COMPARATOR); } myDialectComboBox.setModel(new CollectionComboBoxModel<>(items)); boolean visible = items.size() > 1; myDialectLabel.setVisible(visible); myDialectComboBox.setVisible(visible); if (visible && (myExternalDocument || lastUsed != null)) { VirtualFile file = myExternalDocument ? FileDocumentManager.getInstance().getFile(myEditor.getDocument()) : null; Language curLanguage = LanguageUtil.getLanguageForPsi(myProject, file); int idx = items.indexOf(curLanguage); myDialectComboBox.setSelectedIndex(Math.max(idx, 0)); } }