IntentionAction (final @IntentionName String text, final @IntentionFamilyName String family, final @Nls String listTitle, final List<String> targetList, final String qualifiedName) { return new IntentionAction() { @Override @NotNull public String getText() { return text; } @Override @NotNull public String getFamilyName() { return family; } @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { return true; } @Override public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { targetList.add(qualifiedName); Collections.sort(targetList); ProjectInspectionProfileManager.getInstance(project).fireProfileChanged(); } @Override public boolean startInWriteAction() { return false; } @Override public @NotNull IntentionPreviewInfo generatePreview(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { List<@NlsSafe String> prefixes = StreamEx.of(targetList).append(qualifiedName).sorted().toList(); return IntentionPreviewInfo.addListOption(prefixes, qualifiedName, listTitle); } }; }