Search in sources :

Example 1 with AnalysisResultIssues

use of org.sonarlint.intellij.issue.AnalysisResultIssues in project sonarlint-intellij by SonarSource.

the class SonarClearAnalysisResultsActionTest method clear.

@Test
public void clear() {
    AnalysisResultIssues analysisResultIssues = mock(AnalysisResultIssues.class);
    super.register(AnalysisResultIssues.class, analysisResultIssues);
    AnActionEvent event = mock(AnActionEvent.class);
    when(event.getProject()).thenReturn(project);
    action.actionPerformed(event);
    verify(analysisResultIssues).clear();
}
Also used : AnalysisResultIssues(org.sonarlint.intellij.issue.AnalysisResultIssues) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) SonarTest(org.sonarlint.intellij.SonarTest) Test(org.junit.Test)

Example 2 with AnalysisResultIssues

use of org.sonarlint.intellij.issue.AnalysisResultIssues in project sonarlint-intellij by SonarSource.

the class SonarLintCheckinHandler method processResult.

private ReturnResult processResult(Collection<VirtualFile> affectedFiles) {
    AnalysisResultIssues analysisResultIssues = SonarLintUtils.get(project, AnalysisResultIssues.class);
    IssueManager issueManager = SonarLintUtils.get(project, IssueManager.class);
    Map<VirtualFile, Collection<LiveIssue>> map = affectedFiles.stream().collect(Collectors.toMap(Function.identity(), issueManager::getForFile));
    long numIssues = map.entrySet().stream().flatMap(e -> e.getValue().stream()).filter(i -> !i.isResolved()).count();
    analysisResultIssues.set(map, "SCM changed files");
    long numBlockerIssues = map.entrySet().stream().flatMap(e -> e.getValue().stream()).filter(i -> !i.isResolved()).filter(i -> "BLOCKER".equals(i.getSeverity())).count();
    if (numIssues == 0) {
        return ReturnResult.COMMIT;
    }
    long numFiles = map.keySet().size();
    String msg = createMessage(numFiles, numIssues, numBlockerIssues);
    if (ApplicationManager.getApplication().isHeadlessEnvironment()) {
        LOGGER.info(msg);
        return ReturnResult.CANCEL;
    }
    return showYesNoCancel(msg);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) UIUtil(com.intellij.util.ui.UIUtil) VirtualFile(com.intellij.openapi.vfs.VirtualFile) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) PairConsumer(com.intellij.util.PairConsumer) Function(java.util.function.Function) IssuesViewTabOpener(org.sonarlint.intellij.actions.IssuesViewTabOpener) CheckinHandler(com.intellij.openapi.vcs.checkin.CheckinHandler) Map(java.util.Map) SonarLintGlobalSettings(org.sonarlint.intellij.config.global.SonarLintGlobalSettings) Project(com.intellij.openapi.project.Project) Messages(com.intellij.openapi.ui.Messages) Logger(com.intellij.openapi.diagnostic.Logger) BorderLayout(java.awt.BorderLayout) CommitExecutor(com.intellij.openapi.vcs.changes.CommitExecutor) JComponent(javax.swing.JComponent) IssueManager(org.sonarlint.intellij.issue.IssueManager) SonarLintUtils(org.sonarlint.intellij.util.SonarLintUtils) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) DumbService(com.intellij.openapi.project.DumbService) CheckinProjectPanel(com.intellij.openapi.vcs.CheckinProjectPanel) AnalysisCallback(org.sonarlint.intellij.analysis.AnalysisCallback) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) RefreshableOnComponent(com.intellij.openapi.vcs.ui.RefreshableOnComponent) NonFocusableCheckBox(com.intellij.ui.NonFocusableCheckBox) Nullable(org.jetbrains.annotations.Nullable) ServiceManager(com.intellij.openapi.components.ServiceManager) AnalysisResultIssues(org.sonarlint.intellij.issue.AnalysisResultIssues) JCheckBox(javax.swing.JCheckBox) ApplicationManager(com.intellij.openapi.application.ApplicationManager) LiveIssue(org.sonarlint.intellij.issue.LiveIssue) JPanel(javax.swing.JPanel) IssueManager(org.sonarlint.intellij.issue.IssueManager) Collection(java.util.Collection) AnalysisResultIssues(org.sonarlint.intellij.issue.AnalysisResultIssues)

Example 3 with AnalysisResultIssues

use of org.sonarlint.intellij.issue.AnalysisResultIssues in project sonarlint-intellij by SonarSource.

the class SonarClearAnalysisResultsAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    Project project = e.getProject();
    if (project == null) {
        return;
    }
    AnalysisResultIssues store = SonarLintUtils.get(project, AnalysisResultIssues.class);
    store.clear();
}
Also used : Project(com.intellij.openapi.project.Project) AnalysisResultIssues(org.sonarlint.intellij.issue.AnalysisResultIssues)

Aggregations

AnalysisResultIssues (org.sonarlint.intellij.issue.AnalysisResultIssues)3 Project (com.intellij.openapi.project.Project)2 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 ServiceManager (com.intellij.openapi.components.ServiceManager)1 Logger (com.intellij.openapi.diagnostic.Logger)1 DumbService (com.intellij.openapi.project.DumbService)1 Messages (com.intellij.openapi.ui.Messages)1 CheckinProjectPanel (com.intellij.openapi.vcs.CheckinProjectPanel)1 CommitExecutor (com.intellij.openapi.vcs.changes.CommitExecutor)1 CheckinHandler (com.intellij.openapi.vcs.checkin.CheckinHandler)1 RefreshableOnComponent (com.intellij.openapi.vcs.ui.RefreshableOnComponent)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 NonFocusableCheckBox (com.intellij.ui.NonFocusableCheckBox)1 PairConsumer (com.intellij.util.PairConsumer)1 UIUtil (com.intellij.util.ui.UIUtil)1 BorderLayout (java.awt.BorderLayout)1 Collection (java.util.Collection)1 Map (java.util.Map)1