List<AnAction> (Project project, Editor editor, PsiFile file, Map<Surrounder, PsiElement[]> surrounders) { List<AnAction> applicable = new ArrayList<>(); Set<Character> usedMnemonicsSet = new HashSet<>(); int index = 0; for (Map.Entry<Surrounder, PsiElement[]> entry : surrounders.entrySet()) { Surrounder surrounder = entry.getKey(); PsiElement[] elements = entry.getValue(); if (surrounder.isApplicable(elements)) { char mnemonic; if (index < 9) { mnemonic = (char)('0' + index + 1); } else if (index == 9) { mnemonic = '0'; } else { mnemonic = (char)('A' + index - 10); } index++; usedMnemonicsSet.add(Character.toUpperCase(mnemonic)); applicable.add(new InvokeSurrounderAction(surrounder, project, editor, elements, mnemonic)); } } List<AnAction> templateGroup = SurroundWithTemplateHandler.createActionGroup(editor, file, usedMnemonicsSet); if (!templateGroup.isEmpty()) { applicable.add(new Separator(IdeBundle.messagePointer("action.Anonymous.text.live.templates"))); applicable.addAll(templateGroup); applicable.add(Separator.getInstance()); applicable.add(new ConfigureTemplatesAction()); } return applicable.isEmpty() ? null : applicable; }