void (final Project project, final Editor editor, final PsiFile file, final Consumer<? super DomFileElement<IdeaPlugin>> consumer) { final Module module = ModuleUtilCore.findModuleForPsiElement(file); assert module != null; List<DomFileElement<IdeaPlugin>> elements = DomService.getInstance().getFileElements(IdeaPlugin.class, project, module.getModuleWithDependentsScope()); elements = ContainerUtil.filter(elements, element -> { VirtualFile virtualFile = element.getFile().getVirtualFile(); return virtualFile != null && ProjectRootManager.getInstance(project).getFileIndex().isInContent(virtualFile); }); elements = findAppropriateIntelliJModule(module.getName(), elements); if (elements.isEmpty()) { HintManager.getInstance().showErrorHint(editor, DevKitBundle.message("plugin.descriptor.chooser.cannot.find")); return; } if (elements.size() == 1) { consumer.consume(elements.get(0)); return; } final BaseListPopupStep<PluginDescriptorCandidate> popupStep = new BaseListPopupStep<>(DevKitBundle.message("plugin.descriptor.chooser.popup.title"), createCandidates(module, elements)) { @Override public boolean isSpeedSearchEnabled() { return true; } @Override public Icon getIconFor(PluginDescriptorCandidate candidate) { return candidate.getIcon(); } @Override public @NotNull String getTextFor(PluginDescriptorCandidate candidate) { return candidate.getText(); } @Override public @Nullable ListSeparator getSeparatorAbove(PluginDescriptorCandidate candidate) { final String separatorText = candidate.getSeparatorText(); if (separatorText != null) { return new ListSeparator(separatorText); } return null; } @Override public PopupStep onChosen(PluginDescriptorCandidate selectedValue, boolean finalChoice) { consumer.consume(selectedValue.myDomFileElement); return FINAL_CHOICE; } }; JBPopupFactory.getInstance().createListPopup(popupStep).showInBestPositionFor(editor); }