Search in sources :

Example 1 with ProjectBindingManager

use of org.sonarlint.intellij.core.ProjectBindingManager in project sonarlint-intellij by SonarSource.

the class SonarLinkHandlerTest method prepare.

@Before
public void prepare() throws InvalidBindingException {
    ProjectBindingManager projectBindingManager = mock(ProjectBindingManager.class);
    sonarlint = mock(SonarLintFacade.class);
    editor = mock(Editor.class);
    handler = new SonarLinkHandler();
    when(projectBindingManager.getFacade()).thenReturn(sonarlint);
    when(editor.getProject()).thenReturn(project);
    when(sonarlint.getDescription(RULE_KEY)).thenReturn("description");
    when(sonarlint.getRuleName(RULE_KEY)).thenReturn("name");
    register(ProjectBindingManager.class, projectBindingManager);
}
Also used : ProjectBindingManager(org.sonarlint.intellij.core.ProjectBindingManager) Editor(com.intellij.openapi.editor.Editor) SonarLintFacade(org.sonarlint.intellij.core.SonarLintFacade) Before(org.junit.Before)

Example 2 with ProjectBindingManager

use of org.sonarlint.intellij.core.ProjectBindingManager in project sonarlint-intellij by SonarSource.

the class SonarLintToolWindowFactory method addAnalysisResultsTab.

private static void addAnalysisResultsTab(Project project, ToolWindow toolWindow) {
    ProjectBindingManager projectBindingManager = SonarLintUtils.get(project, ProjectBindingManager.class);
    SonarLintAnalysisResultsPanel resultsPanel = new SonarLintAnalysisResultsPanel(project, projectBindingManager);
    Content analysisResultsContent = toolWindow.getContentManager().getFactory().createContent(resultsPanel, TAB_ANALYSIS_RESULTS, false);
    toolWindow.getContentManager().addDataProvider(resultsPanel);
    toolWindow.getContentManager().addContent(analysisResultsContent);
}
Also used : Content(com.intellij.ui.content.Content) ProjectBindingManager(org.sonarlint.intellij.core.ProjectBindingManager)

Example 3 with ProjectBindingManager

use of org.sonarlint.intellij.core.ProjectBindingManager in project sonarlint-intellij by SonarSource.

the class SonarLintToolWindowFactory method addIssuesTab.

private static void addIssuesTab(Project project, ToolWindow toolWindow) {
    ProjectBindingManager projectBindingManager = SonarLintUtils.get(project, ProjectBindingManager.class);
    IssueManager issueManager = SonarLintUtils.get(project, IssueManager.class);
    CurrentFileController scope = new CurrentFileController(project, issueManager);
    SonarLintIssuesPanel issuesPanel = new SonarLintIssuesPanel(project, projectBindingManager, scope);
    Content issuesContent = toolWindow.getContentManager().getFactory().createContent(issuesPanel, TAB_CURRENT_FILE, false);
    toolWindow.getContentManager().addDataProvider(issuesPanel);
    toolWindow.getContentManager().addContent(issuesContent);
}
Also used : IssueManager(org.sonarlint.intellij.issue.IssueManager) Content(com.intellij.ui.content.Content) ProjectBindingManager(org.sonarlint.intellij.core.ProjectBindingManager)

Example 4 with ProjectBindingManager

use of org.sonarlint.intellij.core.ProjectBindingManager in project sonarlint-intellij by SonarSource.

the class SonarLinkHandler method getDescription.

@Nullable
@Override
public String getDescription(@NotNull String refSuffix, @NotNull Editor editor) {
    Project project = editor.getProject();
    if (project == null || project.isDisposed()) {
        return null;
    }
    ProjectBindingManager projectBindingManager = SonarLintUtils.get(project, ProjectBindingManager.class);
    try {
        SonarLintFacade sonarlint = projectBindingManager.getFacade();
        String description = sonarlint.getDescription(refSuffix);
        String name = sonarlint.getRuleName(refSuffix);
        return transform(refSuffix, name, description);
    } catch (InvalidBindingException e) {
        return "";
    }
}
Also used : Project(com.intellij.openapi.project.Project) InvalidBindingException(org.sonarlint.intellij.exception.InvalidBindingException) ProjectBindingManager(org.sonarlint.intellij.core.ProjectBindingManager) SonarLintFacade(org.sonarlint.intellij.core.SonarLintFacade) Nullable(javax.annotation.Nullable)

Example 5 with ProjectBindingManager

use of org.sonarlint.intellij.core.ProjectBindingManager 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)

Aggregations

ProjectBindingManager (org.sonarlint.intellij.core.ProjectBindingManager)6 Content (com.intellij.ui.content.Content)2 SonarLintFacade (org.sonarlint.intellij.core.SonarLintFacade)2 InvalidBindingException (org.sonarlint.intellij.exception.InvalidBindingException)2 Editor (com.intellij.openapi.editor.Editor)1 Project (com.intellij.openapi.project.Project)1 Nullable (javax.annotation.Nullable)1 Before (org.junit.Before)1 SonarQubeServer (org.sonarlint.intellij.config.global.SonarQubeServer)1 IssueManager (org.sonarlint.intellij.issue.IssueManager)1 ProjectConfigurationListener (org.sonarlint.intellij.messages.ProjectConfigurationListener)1 ServerUpdateTask (org.sonarlint.intellij.tasks.ServerUpdateTask)1 ConnectedSonarLintEngine (org.sonarsource.sonarlint.core.client.api.connected.ConnectedSonarLintEngine)1 LoadedAnalyzer (org.sonarsource.sonarlint.core.client.api.connected.LoadedAnalyzer)1