Search in sources :

Example 1 with SonarLintGlobalSettings

use of org.sonarlint.intellij.config.global.SonarLintGlobalSettings in project sonarlint-intellij by SonarSource.

the class LocalFileExclusions method subscribeToSettingsChanges.

private void subscribeToSettingsChanges(Project project) {
    MessageBusConnection busConnection = project.getMessageBus().connect(project);
    busConnection.subscribe(GlobalConfigurationListener.TOPIC, new GlobalConfigurationListener.Adapter() {

        @Override
        public void applied(SonarLintGlobalSettings newSettings) {
            loadGlobalExclusions(newSettings);
        }
    });
    busConnection.subscribe(ProjectConfigurationListener.TOPIC, this::loadProjectExclusions);
}
Also used : SonarLintGlobalSettings(org.sonarlint.intellij.config.global.SonarLintGlobalSettings) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) GlobalConfigurationListener(org.sonarlint.intellij.messages.GlobalConfigurationListener)

Example 2 with SonarLintGlobalSettings

use of org.sonarlint.intellij.config.global.SonarLintGlobalSettings in project sonarlint-intellij by SonarSource.

the class EditorChangeTriggerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    SonarLintTestUtils.mockMessageBus(project);
    when(editorFactory.getEventMulticaster()).thenReturn(mock(EditorEventMulticaster.class));
    globalSettings = new SonarLintGlobalSettings();
    globalSettings.setAutoTrigger(true);
    listener = new EditorChangeTrigger(project, globalSettings, submitter, editorFactory, utils, docManager, 500);
    listener.initComponent();
}
Also used : SonarLintGlobalSettings(org.sonarlint.intellij.config.global.SonarLintGlobalSettings) EditorEventMulticaster(com.intellij.openapi.editor.event.EditorEventMulticaster) Before(org.junit.Before)

Example 3 with SonarLintGlobalSettings

use of org.sonarlint.intellij.config.global.SonarLintGlobalSettings in project sonarlint-intellij by SonarSource.

the class SonarLintCheckinHandlerTest method prepare.

@Before
public void prepare() {
    globalSettings = new SonarLintGlobalSettings();
    future = new CompletableFuture<>();
    super.register(project, SonarLintSubmitter.class, submitter);
    super.register(project, AnalysisResultIssues.class, analysisResultIssues);
    super.register(project, IssueManager.class, issueManager);
    when(checkinProjectPanel.getVirtualFiles()).thenReturn(Collections.singleton(file));
}
Also used : SonarLintGlobalSettings(org.sonarlint.intellij.config.global.SonarLintGlobalSettings) Before(org.junit.Before)

Example 4 with SonarLintGlobalSettings

use of org.sonarlint.intellij.config.global.SonarLintGlobalSettings in project sonarlint-intellij by SonarSource.

the class SonarLintSubmitterTest method start.

@Before
public void start() throws InvalidBindingException {
    when(bindingManager.getFacade()).thenReturn(facade);
    when(facade.getExcluded(anyCollection(), any(Predicate.class))).thenReturn(Collections.emptySet());
    globalSettings = new SonarLintGlobalSettings();
    globalSettings.setAutoTrigger(true);
    super.register(module, VirtualFileTestPredicate.class, testPredicate);
    submitter = new SonarLintSubmitter(project, console, fileEditorManager, sonarLintJobManager, globalSettings, utils, exclusions, bindingManager);
}
Also used : SonarLintGlobalSettings(org.sonarlint.intellij.config.global.SonarLintGlobalSettings) VirtualFileTestPredicate(org.sonarlint.intellij.analysis.VirtualFileTestPredicate) Predicate(java.util.function.Predicate) Before(org.junit.Before)

Example 5 with SonarLintGlobalSettings

use of org.sonarlint.intellij.config.global.SonarLintGlobalSettings in project sonarlint-intellij by SonarSource.

the class GlobalConfigurationListenerTest method testApplied.

@Test
public void testApplied() {
    List<SonarQubeServer> servers = new LinkedList<>();
    AtomicBoolean bool = new AtomicBoolean(false);
    GlobalConfigurationListener listener = new GlobalConfigurationListener.Adapter() {

        @Override
        public void applied(SonarLintGlobalSettings settings) {
            servers.addAll(settings.getSonarQubeServers());
            bool.set(settings.isAutoTrigger());
        }
    };
    project.getMessageBus().connect().subscribe(GlobalConfigurationListener.TOPIC, listener);
    SonarLintGlobalSettings settings = new SonarLintGlobalSettings();
    settings.setSonarQubeServers(testList);
    settings.setAutoTrigger(true);
    project.getMessageBus().syncPublisher(GlobalConfigurationListener.TOPIC).applied(settings);
    assertThat(servers).isEqualTo(testList);
    assertThat(bool.get()).isTrue();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SonarLintGlobalSettings(org.sonarlint.intellij.config.global.SonarLintGlobalSettings) SonarQubeServer(org.sonarlint.intellij.config.global.SonarQubeServer) LinkedList(java.util.LinkedList) SonarTest(org.sonarlint.intellij.SonarTest) Test(org.junit.Test)

Aggregations

SonarLintGlobalSettings (org.sonarlint.intellij.config.global.SonarLintGlobalSettings)10 Before (org.junit.Before)7 MessageBusConnection (com.intellij.util.messages.MessageBusConnection)2 GlobalConfigurationListener (org.sonarlint.intellij.messages.GlobalConfigurationListener)2 ConnectedSonarLintEngine (org.sonarsource.sonarlint.core.client.api.connected.ConnectedSonarLintEngine)2 StandaloneSonarLintEngine (org.sonarsource.sonarlint.core.client.api.standalone.StandaloneSonarLintEngine)2 EditorEventMulticaster (com.intellij.openapi.editor.event.EditorEventMulticaster)1 FileEditorManagerAdapter (com.intellij.openapi.fileEditor.FileEditorManagerAdapter)1 FileEditorManagerEvent (com.intellij.openapi.fileEditor.FileEditorManagerEvent)1 Project (com.intellij.openapi.project.Project)1 LinkedList (java.util.LinkedList)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Predicate (java.util.function.Predicate)1 Test (org.junit.Test)1 SonarTest (org.sonarlint.intellij.SonarTest)1 VirtualFileTestPredicate (org.sonarlint.intellij.analysis.VirtualFileTestPredicate)1 SonarQubeServer (org.sonarlint.intellij.config.global.SonarQubeServer)1 SonarLintProjectSettings (org.sonarlint.intellij.config.project.SonarLintProjectSettings)1 SonarLintConsole (org.sonarlint.intellij.ui.SonarLintConsole)1