void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { DataManager.getInstance() .getDataContextFromFocusAsync() .onSuccess(context -> { final String wordToSave = myWord != null ? myWord : ProblemDescriptorUtil.extractHighlightedText(descriptor, descriptor.getPsiElement()); final VirtualFile file = descriptor.getPsiElement().getContainingFile().getVirtualFile(); if (myLevel == DictionaryLevel.NOT_SPECIFIED) { final List<String> dictionaryList = Arrays.asList(DictionaryLevel.PROJECT.getName(), DictionaryLevel.APP.getName()); final JBList<String> dictList = new JBList<>(dictionaryList); JBPopupFactory.getInstance() .createListPopupBuilder(dictList) .setTitle(SpellCheckerBundle.message("select.dictionary.title")) .setItemChosenCallback( () -> CommandProcessor.getInstance().executeCommand( project, () -> acceptWord(wordToSave, DictionaryLevel.getLevelByName(dictList.getSelectedValue()), descriptor), getName(), null ) ) .createPopup() .showInBestPositionFor(context); } else { acceptWord(wordToSave, myLevel, descriptor); } }); }