Search in sources :

Example 1 with SonarLintSubmitter

use of org.sonarlint.intellij.trigger.SonarLintSubmitter in project sonarlint-intellij by SonarSource.

the class SonarAnalyzeFilesAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    Project project = e.getProject();
    VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
    if (project == null || project.isDisposed() || files == null || files.length == 0) {
        return;
    }
    boolean hasProject = Arrays.stream(files).anyMatch(f -> f.getPath().equals(project.getBasePath()));
    if (hasProject && !SonarAnalyzeAllFilesAction.showWarning()) {
        return;
    }
    List<VirtualFile> fileList = Arrays.stream(files).flatMap(f -> {
        if (f.isDirectory()) {
            return VfsUtil.collectChildrenRecursively(f).stream();
        } else {
            return Stream.of(f);
        }
    }).distinct().collect(Collectors.toList());
    SonarLintSubmitter submitter = SonarLintUtils.get(project, SonarLintSubmitter.class);
    AnalysisCallback callback;
    if (SonarLintToolWindowFactory.TOOL_WINDOW_ID.equals(e.getPlace())) {
        callback = new ShowCurrentFileCallable(project);
    } else {
        callback = new ShowAnalysisResultsCallable(project, fileList, whatAnalyzed(fileList.size()));
    }
    submitter.submitFiles(fileList, TriggerType.ACTION, callback, executeBackground(e));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) SonarLintSubmitter(org.sonarlint.intellij.trigger.SonarLintSubmitter) AnalysisCallback(org.sonarlint.intellij.analysis.AnalysisCallback)

Example 2 with SonarLintSubmitter

use of org.sonarlint.intellij.trigger.SonarLintSubmitter in project sonarlint-intellij by SonarSource.

the class SonarAnalyzeAllFilesAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    Project project = e.getProject();
    if (project == null || ActionPlaces.PROJECT_VIEW_POPUP.equals(e.getPlace()) || !showWarning()) {
        return;
    }
    SonarLintSubmitter submitter = SonarLintUtils.get(project, SonarLintSubmitter.class);
    Collection<VirtualFile> allFiles = getAllFiles(project);
    AnalysisCallback callback = new ShowAnalysisResultsCallable(project, allFiles, "all project files");
    submitter.submitFiles(allFiles, TriggerType.ALL, callback, false);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) SonarLintSubmitter(org.sonarlint.intellij.trigger.SonarLintSubmitter) AnalysisCallback(org.sonarlint.intellij.analysis.AnalysisCallback)

Example 3 with SonarLintSubmitter

use of org.sonarlint.intellij.trigger.SonarLintSubmitter in project sonarlint-intellij by SonarSource.

the class SonarAnalyzeChangedFilesAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    Project project = e.getProject();
    if (project == null || ActionPlaces.PROJECT_VIEW_POPUP.equals(e.getPlace())) {
        return;
    }
    SonarLintSubmitter submitter = SonarLintUtils.get(project, SonarLintSubmitter.class);
    ChangeListManager changeListManager = ChangeListManager.getInstance(project);
    List<VirtualFile> affectedFiles = changeListManager.getAffectedFiles();
    AnalysisCallback callback = new ShowAnalysisResultsCallable(project, affectedFiles, "SCM changed files");
    submitter.submitFiles(affectedFiles, TriggerType.CHANGED_FILES, callback, false);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) SonarLintSubmitter(org.sonarlint.intellij.trigger.SonarLintSubmitter) AnalysisCallback(org.sonarlint.intellij.analysis.AnalysisCallback) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager)

Example 4 with SonarLintSubmitter

use of org.sonarlint.intellij.trigger.SonarLintSubmitter in project sonarlint-intellij by SonarSource.

the class ServerUpdateTask method analyzeOpenFiles.

private static void analyzeOpenFiles(Project project) {
    if (!project.isDisposed()) {
        SonarLintConsole console = SonarLintConsole.get(project);
        console.info("Clearing all issues because binding was updated");
        IssueManager store = SonarLintUtils.get(project, IssueManager.class);
        store.clear();
        SonarLintSubmitter submitter = SonarLintUtils.get(project, SonarLintSubmitter.class);
        submitter.submitOpenFilesAuto(TriggerType.BINDING_UPDATE);
    }
}
Also used : SonarLintSubmitter(org.sonarlint.intellij.trigger.SonarLintSubmitter) IssueManager(org.sonarlint.intellij.issue.IssueManager) SonarLintConsole(org.sonarlint.intellij.ui.SonarLintConsole)

Aggregations

SonarLintSubmitter (org.sonarlint.intellij.trigger.SonarLintSubmitter)4 Project (com.intellij.openapi.project.Project)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 AnalysisCallback (org.sonarlint.intellij.analysis.AnalysisCallback)3 ChangeListManager (com.intellij.openapi.vcs.changes.ChangeListManager)1 IssueManager (org.sonarlint.intellij.issue.IssueManager)1 SonarLintConsole (org.sonarlint.intellij.ui.SonarLintConsole)1