use of org.sonarlint.intellij.issue.IssueManager in project sonarlint-intellij by SonarSource.
the class SonarClearIssuesAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getProject();
ApplicationManager.getApplication().assertReadAccessAllowed();
if (project != null) {
IssueManager issueManager = SonarLintUtils.get(project, IssueManager.class);
DaemonCodeAnalyzer codeAnalyzer = SonarLintUtils.get(project, DaemonCodeAnalyzer.class);
AccessToken token = ReadAction.start();
try {
issueManager.clear();
// run annotator to remove highlighting of issues
FileEditorManager editorManager = FileEditorManager.getInstance(project);
VirtualFile[] openFiles = editorManager.getOpenFiles();
Collection<PsiFile> psiFiles = findFiles(project, openFiles);
psiFiles.forEach(codeAnalyzer::restart);
} finally {
// closeable only introduced in 2016.2
token.finish();
}
}
}
use of org.sonarlint.intellij.issue.IssueManager in project sonarlint-intellij by SonarSource.
the class SonarLintToolWindowFactory method addIssuesTab.
private static void addIssuesTab(Project project, ToolWindow toolWindow) {
ProjectBindingManager projectBindingManager = SonarLintUtils.get(project, ProjectBindingManager.class);
IssueManager issueManager = SonarLintUtils.get(project, IssueManager.class);
CurrentFileController scope = new CurrentFileController(project, issueManager);
SonarLintIssuesPanel issuesPanel = new SonarLintIssuesPanel(project, projectBindingManager, scope);
Content issuesContent = toolWindow.getContentManager().getFactory().createContent(issuesPanel, TAB_CURRENT_FILE, false);
toolWindow.getContentManager().addDataProvider(issuesPanel);
toolWindow.getContentManager().addContent(issuesContent);
}
use of org.sonarlint.intellij.issue.IssueManager in project sonarlint-intellij by SonarSource.
the class SonarExternalAnnotator method collectInformation.
@Override
public AnnotationContext collectInformation(@NotNull PsiFile file) {
Project project = file.getProject();
IssueManager store = SonarLintUtils.get(project, IssueManager.class);
return new AnnotationContext(store);
}
use of org.sonarlint.intellij.issue.IssueManager 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);
}
use of org.sonarlint.intellij.issue.IssueManager 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);
}
}
Aggregations