Search in sources :

Example 6 with ConnectedSonarLintEngine

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

the class SonarLintEngineManager method getConnectedEngine.

public synchronized ConnectedSonarLintEngine getConnectedEngine(String serverId) {
    if (!engines.containsKey(serverId)) {
        ConnectedSonarLintEngine engine = engineFactory.createEngine(serverId);
        engines.put(serverId, engine);
    }
    return engines.get(serverId);
}
Also used : ConnectedSonarLintEngine(org.sonarsource.sonarlint.core.client.api.connected.ConnectedSonarLintEngine)

Example 7 with ConnectedSonarLintEngine

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

the class SonarLintProjectBindPanel method downloadProjectList.

/**
 * Assumes that it's bound and a server is selected
 */
@CheckForNull
private Map<String, RemoteModule> downloadProjectList() {
    ApplicationManager.getApplication().assertIsDispatchThread();
    SonarQubeServer selectedServer = getSelectedServer();
    String storageId = getSelectedStorageId();
    if (selectedServer == null || storageId == null) {
        return null;
    }
    SonarLintEngineManager core = SonarLintUtils.get(SonarLintEngineManager.class);
    ConnectedSonarLintEngine engine = core.getConnectedEngine(storageId);
    ServerDownloadProjectTask downloadTask = new ServerDownloadProjectTask(project, engine, selectedServer);
    try {
        ProgressManager.getInstance().run(downloadTask);
        return downloadTask.getResult();
    } catch (Exception e) {
        String msg = e.getMessage() != null ? e.getMessage() : "Failed to download list of projects";
        Messages.showErrorDialog(rootPanel, msg, "Error Downloading Project List");
        return null;
    }
}
Also used : SonarQubeServer(org.sonarlint.intellij.config.global.SonarQubeServer) ServerDownloadProjectTask(org.sonarlint.intellij.tasks.ServerDownloadProjectTask) SonarLintEngineManager(org.sonarlint.intellij.core.SonarLintEngineManager) ConnectedSonarLintEngine(org.sonarsource.sonarlint.core.client.api.connected.ConnectedSonarLintEngine) CheckForNull(javax.annotation.CheckForNull)

Example 8 with ConnectedSonarLintEngine

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

the class SonarLintProjectConfigurable method onSave.

/**
 * When we save the binding, we need to:
 * - Send a message for listeners interested in it
 * - If we are bound to a module, update it (even if we detected no changes)
 * - Clear all issues and submit an analysis on all open files
 */
private void onSave() {
    SonarLintProjectNotifications.get(project).reset();
    ProjectConfigurationListener projectListener = project.getMessageBus().syncPublisher(ProjectConfigurationListener.TOPIC);
    if (projectSettings.isBindingEnabled() && projectSettings.getProjectKey() != null && projectSettings.getServerId() != null) {
        ProjectBindingManager bindingManager = SonarLintUtils.get(project, ProjectBindingManager.class);
        try {
            SonarQubeServer server = bindingManager.getSonarQubeServer();
            ConnectedSonarLintEngine engine = bindingManager.getConnectedEngineSkipChecks();
            String moduleKey = projectSettings.getProjectKey();
            ServerUpdateTask task = new ServerUpdateTask(engine, server, Collections.singletonMap(moduleKey, Collections.singletonList(project)), true);
            ProgressManager.getInstance().run(task.asModal());
        } catch (InvalidBindingException e) {
        // nothing to do, SonarLintEngineManager should have already shown a warning
        }
    }
    projectListener.changed(projectSettings);
}
Also used : ServerUpdateTask(org.sonarlint.intellij.tasks.ServerUpdateTask) ProjectConfigurationListener(org.sonarlint.intellij.messages.ProjectConfigurationListener) InvalidBindingException(org.sonarlint.intellij.exception.InvalidBindingException) SonarQubeServer(org.sonarlint.intellij.config.global.SonarQubeServer) ProjectBindingManager(org.sonarlint.intellij.core.ProjectBindingManager) ConnectedSonarLintEngine(org.sonarsource.sonarlint.core.client.api.connected.ConnectedSonarLintEngine)

Example 9 with ConnectedSonarLintEngine

use of org.sonarsource.sonarlint.core.client.api.connected.ConnectedSonarLintEngine 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 10 with ConnectedSonarLintEngine

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

the class ProjectBindingManager method getFacade.

public synchronized SonarLintFacade getFacade(boolean logDetails) throws InvalidBindingException {
    if (projectSettings.isBindingEnabled()) {
        String serverId = projectSettings.getServerId();
        String projectKey = projectSettings.getProjectKey();
        checkBindingStatus(notifications, serverId, projectKey);
        if (logDetails) {
            console.info(String.format("Using configuration of '%s' in server '%s'", projectKey, serverId));
        }
        ConnectedSonarLintEngine engine = engineManager.getConnectedEngine(notifications, serverId, projectKey);
        return new ConnectedSonarLintFacade(engine, projectSettings, console, myProject, projectKey);
    }
    return new StandaloneSonarLintFacade(projectSettings, console, myProject, engineManager.getStandaloneEngine());
}
Also used : ConnectedSonarLintEngine(org.sonarsource.sonarlint.core.client.api.connected.ConnectedSonarLintEngine)

Aggregations

ConnectedSonarLintEngine (org.sonarsource.sonarlint.core.client.api.connected.ConnectedSonarLintEngine)16 Test (org.junit.Test)7 InvalidBindingException (org.sonarlint.intellij.exception.InvalidBindingException)6 SonarQubeServer (org.sonarlint.intellij.config.global.SonarQubeServer)5 ServerConfiguration (org.sonarsource.sonarlint.core.client.api.connected.ServerConfiguration)5 IOException (java.io.IOException)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 Project (com.intellij.openapi.project.Project)2 FileUtil (com.intellij.openapi.util.io.FileUtil)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 Path (java.nio.file.Path)2 Collections (java.util.Collections)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Before (org.junit.Before)2 Rule (org.junit.Rule)2 TemporaryFolder (org.junit.rules.TemporaryFolder)2 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ArgumentMatchers.argThat (org.mockito.ArgumentMatchers.argThat)2