Search in sources :

Example 1 with ClientProgressMonitor

use of org.sonarsource.sonarlint.core.commons.progress.ClientProgressMonitor in project sonarlint-core by SonarSource.

the class ConnectedSonarLintEngineImpl method updateProject.

@Override
public void updateProject(EndpointParams endpoint, HttpClient client, String projectKey, boolean fetchTaintVulnerabilities, @Nullable String branchName, @Nullable ClientProgressMonitor monitor) {
    requireNonNull(endpoint);
    requireNonNull(projectKey);
    setLogging(null);
    var globalStorageStatus = globalStatusReader.read();
    if (globalStorageStatus == null || globalStorageStatus.isStale()) {
        throw new StorageException("Missing or outdated storage for connection '" + globalConfig.getConnectionId() + "'");
    }
    projectStorageUpdateExecutor.update(new ServerApiHelper(endpoint, client), projectKey, fetchTaintVulnerabilities, branchName, new ProgressMonitor(monitor));
}
Also used : ClientProgressMonitor(org.sonarsource.sonarlint.core.commons.progress.ClientProgressMonitor) ProgressMonitor(org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor) ServerApiHelper(org.sonarsource.sonarlint.core.serverapi.ServerApiHelper) StorageException(org.sonarsource.sonarlint.core.client.api.exceptions.StorageException)

Example 2 with ClientProgressMonitor

use of org.sonarsource.sonarlint.core.commons.progress.ClientProgressMonitor 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 3 with ClientProgressMonitor

use of org.sonarsource.sonarlint.core.commons.progress.ClientProgressMonitor 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)

Example 4 with ClientProgressMonitor

use of org.sonarsource.sonarlint.core.commons.progress.ClientProgressMonitor in project sonarlint-core by SonarSource.

the class ConnectedSonarLintEngineImpl method sync.

@Override
public void sync(EndpointParams endpoint, HttpClient client, Set<String> projectKeys, @Nullable ClientProgressMonitor monitor) {
    var serverApi = new ServerApi(new ServerApiHelper(endpoint, client));
    var result = storageSynchronizer.synchronize(serverApi, projectKeys, new ProgressMonitor(monitor));
    if (result.hasAnalyzerBeenUpdated()) {
        restartAnalysisEngine();
    }
}
Also used : ClientProgressMonitor(org.sonarsource.sonarlint.core.commons.progress.ClientProgressMonitor) ProgressMonitor(org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor) ServerApi(org.sonarsource.sonarlint.core.serverapi.ServerApi) ServerApiHelper(org.sonarsource.sonarlint.core.serverapi.ServerApiHelper)

Example 5 with ClientProgressMonitor

use of org.sonarsource.sonarlint.core.commons.progress.ClientProgressMonitor in project sonarlint-core by SonarSource.

the class ConnectedSonarLintEngineImpl method update.

@Override
public UpdateResult update(EndpointParams endpoint, HttpClient client, @Nullable ClientProgressMonitor monitor) {
    requireNonNull(endpoint);
    setLogging(null);
    globalStorageUpdateExecutor.update(new ServerApiHelper(endpoint, client), new ProgressMonitor(monitor));
    return new UpdateResult(globalStatusReader.read());
}
Also used : ClientProgressMonitor(org.sonarsource.sonarlint.core.commons.progress.ClientProgressMonitor) ProgressMonitor(org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor) ServerApiHelper(org.sonarsource.sonarlint.core.serverapi.ServerApiHelper) UpdateResult(org.sonarsource.sonarlint.core.client.api.connected.UpdateResult)

Aggregations

ClientProgressMonitor (org.sonarsource.sonarlint.core.commons.progress.ClientProgressMonitor)5 ProgressMonitor (org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor)5 ServerApiHelper (org.sonarsource.sonarlint.core.serverapi.ServerApiHelper)3 AnalysisResults (org.sonarsource.sonarlint.core.analysis.api.AnalysisResults)2 AnalyzeCommand (org.sonarsource.sonarlint.core.analysis.command.AnalyzeCommand)2 SonarLintWrappedException (org.sonarsource.sonarlint.core.client.api.exceptions.SonarLintWrappedException)2 StorageException (org.sonarsource.sonarlint.core.client.api.exceptions.StorageException)2 DefaultClientIssue (org.sonarsource.sonarlint.core.client.api.common.analysis.DefaultClientIssue)1 UpdateResult (org.sonarsource.sonarlint.core.client.api.connected.UpdateResult)1 DownloadException (org.sonarsource.sonarlint.core.client.api.exceptions.DownloadException)1 ServerApi (org.sonarsource.sonarlint.core.serverapi.ServerApi)1