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);
}
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);
}
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);
}
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 "";
}
}
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);
}
Aggregations