Search in sources :

Example 1 with DefaultClientIssue

use of org.sonarsource.sonarlint.core.client.api.common.analysis.DefaultClientIssue in project sonarlint-core by SonarSource.

the class ConnectedSonarLintEngineImpl method streamIssue.

private static void streamIssue(IssueListener issueListener, Issue newIssue, ActiveRulesContext activeRulesContext) {
    var ruleMetadata = activeRulesContext.getRuleMetadata(newIssue.getRuleKey());
    issueListener.handle(new DefaultClientIssue(newIssue, ruleMetadata.severity, ruleMetadata.type));
}
Also used : DefaultClientIssue(org.sonarsource.sonarlint.core.client.api.common.analysis.DefaultClientIssue)

Example 2 with DefaultClientIssue

use of org.sonarsource.sonarlint.core.client.api.common.analysis.DefaultClientIssue in project sonarlint-core by SonarSource.

the class StandaloneSonarLintEngineImpl method analyze.

@Override
public AnalysisResults analyze(StandaloneAnalysisConfiguration configuration, IssueListener issueListener, @Nullable ClientLogOutput logOutput, @Nullable ClientProgressMonitor monitor) {
    requireNonNull(configuration);
    requireNonNull(issueListener);
    setLogging(logOutput);
    var analysisConfig = AnalysisConfiguration.builder().addInputFiles(configuration.inputFiles()).putAllExtraProperties(configuration.extraProperties()).addActiveRules(identifyActiveRules(configuration)).setBaseDir(configuration.baseDir()).build();
    try {
        var analysisResults = analysisEngine.post(new AnalyzeCommand(configuration.moduleKey(), analysisConfig, i -> issueListener.handle(new DefaultClientIssue(i, allRulesDefinitionsByKey.get(i.getRuleKey()))), logOutput), new ProgressMonitor(monitor)).get();
        return analysisResults == null ? new AnalysisResults() : analysisResults;
    } catch (Exception e) {
        throw SonarLintWrappedException.wrap(e);
    }
}
Also used : ClientProgressMonitor(org.sonarsource.sonarlint.core.commons.progress.ClientProgressMonitor) ProgressMonitor(org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor) AnalysisResults(org.sonarsource.sonarlint.core.analysis.api.AnalysisResults) SonarLintWrappedException(org.sonarsource.sonarlint.core.client.api.exceptions.SonarLintWrappedException) AnalyzeCommand(org.sonarsource.sonarlint.core.analysis.command.AnalyzeCommand) DefaultClientIssue(org.sonarsource.sonarlint.core.client.api.common.analysis.DefaultClientIssue)

Aggregations

DefaultClientIssue (org.sonarsource.sonarlint.core.client.api.common.analysis.DefaultClientIssue)2 AnalysisResults (org.sonarsource.sonarlint.core.analysis.api.AnalysisResults)1 AnalyzeCommand (org.sonarsource.sonarlint.core.analysis.command.AnalyzeCommand)1 SonarLintWrappedException (org.sonarsource.sonarlint.core.client.api.exceptions.SonarLintWrappedException)1 ClientProgressMonitor (org.sonarsource.sonarlint.core.commons.progress.ClientProgressMonitor)1 ProgressMonitor (org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor)1