Search in sources :

Example 1 with AnalysisResults

use of org.sonarsource.sonarlint.core.analysis.api.AnalysisResults 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)

Example 2 with AnalysisResults

use of org.sonarsource.sonarlint.core.analysis.api.AnalysisResults in project sonarlint-core by SonarSource.

the class ModuleContainer method analyze.

public AnalysisResults analyze(AnalysisConfiguration configuration, Consumer<Issue> issueListener, ProgressMonitor progress) {
    var analysisContainer = new AnalysisContainer(this, progress);
    analysisContainer.add(configuration);
    analysisContainer.add(new IssueListenerHolder(issueListener));
    analysisContainer.add(new ActiveRulesAdapter(configuration.activeRules().stream().map(ActiveRuleAdapter::new).collect(Collectors.toList())));
    var defaultAnalysisResult = new AnalysisResults();
    analysisContainer.add(defaultAnalysisResult);
    analysisContainer.execute();
    return defaultAnalysisResult;
}
Also used : AnalysisResults(org.sonarsource.sonarlint.core.analysis.api.AnalysisResults) AnalysisContainer(org.sonarsource.sonarlint.core.analysis.container.analysis.AnalysisContainer) ActiveRulesAdapter(org.sonarsource.sonarlint.core.analysis.sonarapi.ActiveRulesAdapter) IssueListenerHolder(org.sonarsource.sonarlint.core.analysis.container.analysis.IssueListenerHolder)

Example 3 with AnalysisResults

use of org.sonarsource.sonarlint.core.analysis.api.AnalysisResults in project sonarlint-core by SonarSource.

the class ConnectedSonarLintEngineImpl method analyze.

@Override
public AnalysisResults analyze(ConnectedAnalysisConfiguration configuration, IssueListener issueListener, @Nullable ClientLogOutput logOutput, @Nullable ClientProgressMonitor monitor) {
    requireNonNull(configuration);
    requireNonNull(issueListener);
    setLogging(logOutput);
    checkStatus(configuration.projectKey());
    var analysisConfigBuilder = AnalysisConfiguration.builder().addInputFiles(configuration.inputFiles());
    var projectKey = configuration.projectKey();
    if (projectKey != null) {
        analysisConfigBuilder.putAllExtraProperties(projectStorage.getAnalyzerConfiguration(projectKey).getSettings().getAll());
        analysisConfigBuilder.putAllExtraProperties(globalConfig.extraProperties());
    }
    var activeRulesContext = buildActiveRulesContext(configuration);
    analysisConfigBuilder.putAllExtraProperties(configuration.extraProperties()).addActiveRules(activeRulesContext.activeRules).setBaseDir(configuration.baseDir()).build();
    var analysisConfiguration = analysisConfigBuilder.build();
    try {
        var analysisResults = getAnalysisEngine().post(new AnalyzeCommand(configuration.moduleKey(), analysisConfiguration, issue -> streamIssue(issueListener, issue, activeRulesContext), 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) StorageException(org.sonarsource.sonarlint.core.client.api.exceptions.StorageException) SonarLintWrappedException(org.sonarsource.sonarlint.core.client.api.exceptions.SonarLintWrappedException) DownloadException(org.sonarsource.sonarlint.core.client.api.exceptions.DownloadException) AnalyzeCommand(org.sonarsource.sonarlint.core.analysis.command.AnalyzeCommand)

Aggregations

AnalysisResults (org.sonarsource.sonarlint.core.analysis.api.AnalysisResults)3 AnalyzeCommand (org.sonarsource.sonarlint.core.analysis.command.AnalyzeCommand)2 SonarLintWrappedException (org.sonarsource.sonarlint.core.client.api.exceptions.SonarLintWrappedException)2 ClientProgressMonitor (org.sonarsource.sonarlint.core.commons.progress.ClientProgressMonitor)2 ProgressMonitor (org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor)2 AnalysisContainer (org.sonarsource.sonarlint.core.analysis.container.analysis.AnalysisContainer)1 IssueListenerHolder (org.sonarsource.sonarlint.core.analysis.container.analysis.IssueListenerHolder)1 ActiveRulesAdapter (org.sonarsource.sonarlint.core.analysis.sonarapi.ActiveRulesAdapter)1 DefaultClientIssue (org.sonarsource.sonarlint.core.client.api.common.analysis.DefaultClientIssue)1 DownloadException (org.sonarsource.sonarlint.core.client.api.exceptions.DownloadException)1 StorageException (org.sonarsource.sonarlint.core.client.api.exceptions.StorageException)1