void (@NotNull Project project, @NotNull String shortName, @NotNull VirtualFile @NotNull [] virtualFiles, @Nullable PsiElement psiElement, @Nullable PsiFile psiFile) { final PsiElement element = psiFile == null ? psiElement : psiFile; final InspectionProfile currentProfile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile(); final InspectionToolWrapper<?, ?> toolWrapper = element != null ? currentProfile.getInspectionTool(shortName, element) : currentProfile.getInspectionTool(shortName, project); LOGGER.assertTrue(toolWrapper != null, "Missed inspection: " + shortName); final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(project); final Module module = findModuleForFiles(project, virtualFiles); AnalysisScope analysisScope = null; if (psiFile != null) { analysisScope = new AnalysisScope(psiFile); } else { if (virtualFiles.length == 1 && virtualFiles[0].isDirectory()) { final PsiDirectory psiDirectory = PsiManager.getInstance(project).findDirectory(virtualFiles[0]); if (psiDirectory != null) { analysisScope = new AnalysisScope(psiDirectory); } } if (analysisScope == null && virtualFiles.length != 0) { analysisScope = new AnalysisScope(project, ContainerUtil.newHashSet(virtualFiles)); } if (analysisScope == null) { analysisScope = new AnalysisScope(project); } } final AnalysisUIOptions options = AnalysisUIOptions.getInstance(project); final FileFilterPanel fileFilterPanel = new FileFilterPanel(); fileFilterPanel.init(options); final AnalysisScope initialAnalysisScope = analysisScope; List<ModelScopeItem> items = BaseAnalysisActionDialog.standardItems(project, analysisScope, module, psiElement); final BaseAnalysisActionDialog dialog = new BaseAnalysisActionDialog(IdeBundle.message("goto.inspection.action.dialog.title", toolWrapper.getDisplayName()), CodeInsightBundle.message("analysis.scope.title", InspectionsBundle .message("inspection.action.noun")), project, items, options, true) { private InspectionToolWrapper<?, ?> myUpdatedSettingsToolWrapper; @Override protected @NotNull JComponent getAdditionalActionSettings(@NotNull Project project) { final JPanel panel = new JPanel(new GridBagLayout()); final boolean hasOptionsPanel = OptionPaneRenderer.hasSettings(toolWrapper.getTool()); final GridBag constraints = new GridBag() .setDefaultWeightX(1) .setDefaultWeightY(hasOptionsPanel ? 0 : 1) .setDefaultFill(GridBagConstraints.HORIZONTAL); panel.add(fileFilterPanel.getPanel(), constraints.nextLine()); if (hasOptionsPanel) { myUpdatedSettingsToolWrapper = copyToolWithSettings(toolWrapper); final JComponent optionsPanel = OptionPaneRenderer.createOptionsPanel(myUpdatedSettingsToolWrapper.getTool(), myDisposable, project); LOGGER.assertTrue(optionsPanel != null); final var separator = new TitledSeparator(IdeBundle.message("goto.inspection.action.choose.inherit.settings.from")); separator.setBorder(JBUI.Borders.empty()); panel.add(separator, constraints.nextLine().insetTop(20)); optionsPanel.setBorder(InspectionUiUtilKt.getBordersForOptions(optionsPanel)); final var scrollPane = InspectionUiUtilKt.addScrollPaneIfNecessary(optionsPanel); final var preferredSize = scrollPane.getPreferredSize(); scrollPane.setPreferredSize(new Dimension(preferredSize.width, Math.min(preferredSize.height, 400))); panel.add(scrollPane, constraints.nextLine()); } return panel; } @NotNull @Override public AnalysisScope getScope(@NotNull AnalysisScope defaultScope) { final AnalysisScope scope = super.getScope(defaultScope); final GlobalSearchScope filterScope = fileFilterPanel.getSearchScope(); if (filterScope == null) { return scope; } scope.setFilter(filterScope); return scope; } private AnalysisScope getScope() { return getScope(initialAnalysisScope); } private InspectionToolWrapper<?, ?> getToolWrapper() { return myUpdatedSettingsToolWrapper == null ? toolWrapper : myUpdatedSettingsToolWrapper; } @Override protected Action @NotNull [] createActions() { final List<Action> actions = new ArrayList<>(); final boolean hasFixAll = toolWrapper.isCleanupTool(); actions.add(new AbstractAction(hasFixAll ? CodeInsightBundle.message("action.analyze.verb") : CommonBundle.getOkButtonText()) { { putValue(DEFAULT_ACTION, Boolean.TRUE); } @Override public void actionPerformed(ActionEvent e) { AnalysisScope scope = getScope(); InspectionToolWrapper<?, ?> wrapper = getToolWrapper(); DumbService.getInstance(project).smartInvokeLater(() -> RunInspectionIntention.rerunInspection(wrapper, managerEx, scope, null)); close(DialogWrapper.OK_EXIT_CODE); } }); if (hasFixAll) { actions.add(new AbstractAction(IdeBundle.message("goto.inspection.action.fix.all")) { @Override public void actionPerformed(ActionEvent e) { InspectionToolWrapper<?, ?> wrapper = getToolWrapper(); InspectionProfileImpl cleanupToolProfile = RunInspectionIntention.createProfile(wrapper, managerEx, null); managerEx.createNewGlobalContext() .codeCleanup(getScope(), cleanupToolProfile, "Cleanup by " + wrapper.getDisplayName(), null, false); close(DialogWrapper.OK_EXIT_CODE); } }); } actions.add(getCancelAction()); if (SystemInfo.isMac) { Collections.reverse(actions); } return actions.toArray(new Action[0]); } }; //don't show if called for regexp inspection which makes no sense without injection dialog.setShowInspectInjectedCode(!(Language.findLanguageByID(toolWrapper.getLanguage()) instanceof InjectableLanguage)); dialog.showAndGet(); }