Search in sources :

Example 11 with ServerConfiguration

use of org.sonarsource.sonarlint.core.client.api.connected.ServerConfiguration in project sonarlint-intellij by SonarSource.

the class ServerDownloadProjectTask method run.

@Override
public void run(@NotNull ProgressIndicator indicator) {
    try {
        TaskProgressMonitor monitor = new TaskProgressMonitor(indicator);
        ServerConfiguration serverConfiguration = SonarLintUtils.getServerConfiguration(server);
        this.result = engine.downloadAllModules(serverConfiguration, monitor);
    } catch (Exception e) {
        LOGGER.info("Failed to download list of projects", e);
        this.exception = e;
    }
}
Also used : ServerConfiguration(org.sonarsource.sonarlint.core.client.api.connected.ServerConfiguration) TaskProgressMonitor(org.sonarlint.intellij.util.TaskProgressMonitor)

Example 12 with ServerConfiguration

use of org.sonarsource.sonarlint.core.client.api.connected.ServerConfiguration in project sonarlint-intellij by SonarSource.

the class ServerUpdateTask method run.

public void run(@NotNull ProgressIndicator indicator) {
    indicator.setText("Fetching data...");
    try {
        TaskProgressMonitor monitor = new TaskProgressMonitor(indicator);
        ServerConfiguration serverConfiguration = SonarLintUtils.getServerConfiguration(server);
        if (!onlyModules) {
            UpdateResult updateResult = engine.update(serverConfiguration, monitor);
            Collection<SonarAnalyzer> tooOld = updateResult.analyzers().stream().filter(SonarAnalyzer::sonarlintCompatible).filter(ServerUpdateTask::tooOld).collect(Collectors.toList());
            if (!tooOld.isEmpty()) {
                ApplicationManager.getApplication().invokeAndWait(() -> Messages.showWarningDialog(buildMinimumVersionFailMessage(tooOld), "Analyzers Not Loaded"), ModalityState.any());
            }
            log.log("Server binding '" + server.getName() + "' updated", LogOutput.Level.INFO);
        }
        updateModules(serverConfiguration, monitor);
    } catch (CanceledException e) {
        LOGGER.info("Update of server '" + server.getName() + "' was cancelled");
        log.log("Update of server '" + server.getName() + "' was cancelled", LogOutput.Level.INFO);
    } catch (Exception e) {
        LOGGER.info("Error updating from server '" + server.getName() + "'", e);
        final String msg = (e.getMessage() != null) ? e.getMessage() : ("Failed to update binding for server configuration '" + server.getName() + "'");
        ApplicationManager.getApplication().invokeAndWait(new RunnableAdapter() {

            @Override
            public void doRun() {
                Messages.showErrorDialog((Project) null, msg, "Update Failed");
            }
        }, ModalityState.any());
    }
}
Also used : CanceledException(org.sonarsource.sonarlint.core.client.api.exceptions.CanceledException) RunnableAdapter(com.intellij.history.utils.RunnableAdapter) ServerConfiguration(org.sonarsource.sonarlint.core.client.api.connected.ServerConfiguration) SonarAnalyzer(org.sonarsource.sonarlint.core.client.api.connected.SonarAnalyzer) TaskProgressMonitor(org.sonarlint.intellij.util.TaskProgressMonitor) UpdateResult(org.sonarsource.sonarlint.core.client.api.connected.UpdateResult) CanceledException(org.sonarsource.sonarlint.core.client.api.exceptions.CanceledException)

Example 13 with ServerConfiguration

use of org.sonarsource.sonarlint.core.client.api.connected.ServerConfiguration in project sonarlint-core by SonarSource.

the class ServerIssueTrackerTest method should_download_issues_from_engine.

@Test
public void should_download_issues_from_engine() {
    String moduleKey = "dummy module";
    String filePath = "dummy file";
    ConnectedSonarLintEngine engine = mock(ConnectedSonarLintEngine.class);
    ServerConfiguration serverConfiguration = mock(ServerConfiguration.class);
    ServerIssueTracker tracker = new ServerIssueTracker(mock(Logger.class), mock(Console.class), mock(CachingIssueTracker.class));
    tracker.update(serverConfiguration, engine, moduleKey, Collections.singleton(filePath));
    verify(engine).downloadServerIssues(serverConfiguration, moduleKey, filePath);
    verifyNoMoreInteractions(engine);
}
Also used : ServerConfiguration(org.sonarsource.sonarlint.core.client.api.connected.ServerConfiguration) ConnectedSonarLintEngine(org.sonarsource.sonarlint.core.client.api.connected.ConnectedSonarLintEngine) Test(org.junit.Test)

Example 14 with ServerConfiguration

use of org.sonarsource.sonarlint.core.client.api.connected.ServerConfiguration in project sonarlint-core by SonarSource.

the class ConnectedSonarLintImpl method update.

@Override
public void update(ServerConfig request, StreamObserver<Void> response) {
    try {
        ServerConfiguration config = transformServerConfig(request);
        engine.update(config, null);
        response.onNext(Void.newBuilder().build());
        response.onCompleted();
    } catch (Exception e) {
        LOGGER.error("update", e);
        response.onError(e);
    }
}
Also used : ServerConfiguration(org.sonarsource.sonarlint.core.client.api.connected.ServerConfiguration)

Example 15 with ServerConfiguration

use of org.sonarsource.sonarlint.core.client.api.connected.ServerConfiguration in project sonarlint-core by SonarSource.

the class ConnectedSonarLintImpl method updateModule.

@Override
public void updateModule(ModuleUpdateReq request, StreamObserver<Void> response) {
    try {
        ServerConfiguration serverConfig = transformServerConfig(request.getServerConfig());
        engine.updateModule(serverConfig, request.getModuleKey(), null);
        response.onNext(Void.newBuilder().build());
        response.onCompleted();
    } catch (Exception e) {
        LOGGER.error("updateModule", e);
        response.onError(e);
    }
}
Also used : ServerConfiguration(org.sonarsource.sonarlint.core.client.api.connected.ServerConfiguration)

Aggregations

ServerConfiguration (org.sonarsource.sonarlint.core.client.api.connected.ServerConfiguration)22 Test (org.junit.Test)10 ConnectedSonarLintEngine (org.sonarsource.sonarlint.core.client.api.connected.ConnectedSonarLintEngine)6 List (java.util.List)4 Map (java.util.Map)4 WsHelperImpl (org.sonarsource.sonarlint.core.WsHelperImpl)4 WsHelper (org.sonarsource.sonarlint.core.client.api.connected.WsHelper)4 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 Nullable (javax.annotation.Nullable)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 SonarApplication (org.sonarlint.intellij.SonarApplication)3 TaskProgressMonitor (org.sonarlint.intellij.util.TaskProgressMonitor)3 AnalysisResults (org.sonarsource.sonarlint.core.client.api.common.analysis.AnalysisResults)3 ConnectedGlobalConfiguration (org.sonarsource.sonarlint.core.client.api.connected.ConnectedGlobalConfiguration)3 SonarAnalyzer (org.sonarsource.sonarlint.core.client.api.connected.SonarAnalyzer)3 StorageUpdateCheckResult (org.sonarsource.sonarlint.core.client.api.connected.StorageUpdateCheckResult)3 UpdateResult (org.sonarsource.sonarlint.core.client.api.connected.UpdateResult)3 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)2