void (@NotNull AnalysisScope scope, @NotNull InspectionProfile profile, @Nullable String commandName, @Nullable Runnable postRunnable, boolean modal, @NotNull Predicate<? super ProblemDescriptor> shouldApplyFix) { String title = LangBundle.message("progress.title.inspect.code", profile.getName()); if (LOG.isDebugEnabled()) { LOG.debug("Starting code cleanup"); } Task task = modal ? new Task.Modal(getProject(), title, true) { private CleanupProblems problems; @Override public void run(@NotNull ProgressIndicator indicator) { problems = findProblems(scope, profile, indicator, shouldApplyFix); } @Override public void onSuccess() { applyFixes(scope, problems, commandName, postRunnable, profile, true, shouldApplyFix); } @Override public void onThrowable(@NotNull Throwable error) { if (LOG.isDebugEnabled()) { LOG.debug("Code cleanup: an exception during findProblems"); } super.onThrowable(error); } @Override public void onCancel() { if (LOG.isDebugEnabled()) { LOG.debug("Code cleanup: cancelled"); } } @Override public void onFinished() { if (LOG.isDebugEnabled()) { LOG.debug("Code cleanup: finished searching for problems"); } } } : new Task.Backgroundable(getProject(), title, true) { private CleanupProblems problems; @Override public void run(@NotNull ProgressIndicator indicator) { problems = findProblems(scope, profile, indicator, shouldApplyFix); } @Override public void onSuccess() { applyFixes(scope, problems, commandName, postRunnable, profile, false, shouldApplyFix); } @Override public void onThrowable(@NotNull Throwable error) { if (LOG.isDebugEnabled()) { LOG.debug("Code cleanup: an exception during findProblems"); } super.onThrowable(error); } @Override public void onCancel() { if (LOG.isDebugEnabled()) { LOG.debug("Code cleanup: cancelled"); } } @Override public void onFinished() { if (LOG.isDebugEnabled()) { LOG.debug("Code cleanup: finished searching for problems"); } } }; ProgressManager.getInstance().run(task); }