/** * Marks the section of the task as not cancelable */ @Override public void startNonCancelableSection() { indicator.startNonCancelableSection(); }
private List<AnalysisResults> analyze(Project project, ProgressIndicator indicator, AccumulatorIssueListener listener) { SonarLintAnalyzer analyzer = SonarLintUtils.get(project, SonarLintAnalyzer.class); indicator.setIndeterminate(true); int numModules = job.filesPerModule().keySet().size(); String suffix = ""; if (numModules > 1) { suffix = String.format(" in %d modules", numModules); } int numFiles = job.allFiles().size(); if (numFiles > 1) { indicator.setText("Running SonarLint Analysis for " + numFiles + " files" + suffix); } else { indicator.setText("Running SonarLint Analysis for '" + getFileName(job.allFiles().iterator().next()) + "'"); } LOGGER.info(indicator.getText()); ProgressMonitor progressMonitor = new TaskProgressMonitor(indicator); List<AnalysisResults> results = new LinkedList<>(); for (Map.Entry<Module, Collection<VirtualFile>> e : job.filesPerModule().entrySet()) { results.add(analyzer.analyzeModule(e.getKey(), e.getValue(), listener, progressMonitor)); checkCanceled(indicator, myProject); } indicator.startNonCancelableSection(); return results; } }
@Test public void should_wrap() { monitor.finishNonCancelableSection(); verify(wrapped).finishNonCancelableSection(); monitor.isCanceled(); verify(wrapped).isCanceled(); monitor.setFraction(0.5f); verify(wrapped).setFraction(0.5f); monitor.setIndeterminate(true); verify(wrapped).setIndeterminate(true); monitor.setMessage("message"); verify(wrapped).setText("message"); monitor.startNonCancelableSection(); verify(wrapped).startNonCancelableSection(); } }
@Override public void run(@NotNull ProgressIndicator progressIndicator) { progressIndicator.setIndeterminate(true); progressIndicator.startNonCancelableSection(); try { LOG.info("Fetching files into " + rootPath); FetchFilesResult r = P4ServerComponent .perform(project, clientConfig, new FetchFilesAction(Collections.singletonList(rootPath), null, false)) .blockingGet(UserProjectPreferences.getLockWaitTimeoutMillis(project), TimeUnit.MILLISECONDS); progressIndicator.finishNonCancelableSection(); synchronized (sync) { res = r; } } catch (InterruptedException e) { InternalErrorMessage.send(project).cacheLockTimeoutError(new ErrorEvent<>( new VcsInterruptedException(e))); progressIndicator.finishNonCancelableSection(); onCancel(); } catch (P4CommandRunner.ServerResultException e) { progressIndicator.finishNonCancelableSection(); VcsNotifier.getInstance(project).notifyError(P4Bundle.getString("checkout.config.error.title"), e.getMessage()); synchronized (sync) { res = null; } } progressIndicator.stop(); }