Search in sources :

Example 1 with AccumulatorIssueListener

use of org.sonarlint.intellij.editor.AccumulatorIssueListener in project sonarlint-intellij by SonarSource.

the class SonarLintTask method run.

@Override
public void run(ProgressIndicator indicator) {
    AccumulatorIssueListener listener = new AccumulatorIssueListener();
    try {
        checkCanceled(indicator, myProject);
        List<AnalysisResults> results = analyze(myProject, indicator, listener);
        // last chance to cancel (to avoid the possibility of having interrupt flag set)
        checkCanceled(indicator, myProject);
        LOGGER.info("SonarLint analysis done");
        indicator.setIndeterminate(false);
        indicator.setFraction(.9);
        List<Issue> issues = listener.getIssues();
        indicator.setText("Creating SonarLint issues: " + issues.size());
        List<ClientInputFile> allFailedAnalysisFiles = results.stream().flatMap(r -> r.failedAnalysisFiles().stream()).collect(Collectors.toList());
        processor.process(job, indicator, issues, allFailedAnalysisFiles);
    } catch (CanceledException e1) {
        console.info("Analysis canceled");
        return;
    } catch (Throwable e) {
        handleError(e, indicator);
    } finally {
        myProject.getMessageBus().syncPublisher(TaskListener.SONARLINT_TASK_TOPIC).ended(job);
    }
}
Also used : AccumulatorIssueListener(org.sonarlint.intellij.editor.AccumulatorIssueListener) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ModalityState(com.intellij.openapi.application.ModalityState) ClientInputFile(org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile) Task(com.intellij.openapi.progress.Task) Map(java.util.Map) Project(com.intellij.openapi.project.Project) Messages(com.intellij.openapi.ui.Messages) Logger(com.intellij.openapi.diagnostic.Logger) Module(com.intellij.openapi.module.Module) LinkedList(java.util.LinkedList) IssueProcessor(org.sonarlint.intellij.issue.IssueProcessor) SonarLintUtils(org.sonarlint.intellij.util.SonarLintUtils) TaskListener(org.sonarlint.intellij.messages.TaskListener) Collection(java.util.Collection) ProgressMonitor(org.sonarsource.sonarlint.core.client.api.common.ProgressMonitor) Collectors(java.util.stream.Collectors) SonarLintConsole(org.sonarlint.intellij.ui.SonarLintConsole) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) List(java.util.List) AnalysisResults(org.sonarsource.sonarlint.core.client.api.common.analysis.AnalysisResults) CanceledException(org.sonarsource.sonarlint.core.client.api.exceptions.CanceledException) Issue(org.sonarsource.sonarlint.core.client.api.common.analysis.Issue) ApplicationManager(com.intellij.openapi.application.ApplicationManager) TaskProgressMonitor(org.sonarlint.intellij.util.TaskProgressMonitor) CanceledException(org.sonarsource.sonarlint.core.client.api.exceptions.CanceledException) Issue(org.sonarsource.sonarlint.core.client.api.common.analysis.Issue) AnalysisResults(org.sonarsource.sonarlint.core.client.api.common.analysis.AnalysisResults) AccumulatorIssueListener(org.sonarlint.intellij.editor.AccumulatorIssueListener) ClientInputFile(org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile)

Aggregations

ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 ModalityState (com.intellij.openapi.application.ModalityState)1 Logger (com.intellij.openapi.diagnostic.Logger)1 Module (com.intellij.openapi.module.Module)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 Project (com.intellij.openapi.project.Project)1 Messages (com.intellij.openapi.ui.Messages)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Collection (java.util.Collection)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 AccumulatorIssueListener (org.sonarlint.intellij.editor.AccumulatorIssueListener)1 IssueProcessor (org.sonarlint.intellij.issue.IssueProcessor)1 TaskListener (org.sonarlint.intellij.messages.TaskListener)1 SonarLintConsole (org.sonarlint.intellij.ui.SonarLintConsole)1 SonarLintUtils (org.sonarlint.intellij.util.SonarLintUtils)1 TaskProgressMonitor (org.sonarlint.intellij.util.TaskProgressMonitor)1