use of org.sonarsource.sonarlint.core.client.api.connected.ConnectedAnalysisConfiguration in project sonarlint-core by SonarSource.
the class ConnectedStaleStorageMediumTest method test_stale_global.
@Test
public void test_stale_global() throws Exception {
writeUpdateStatus(storage, "0");
ConnectedSonarLintEngine sonarlint = new ConnectedSonarLintEngineImpl(config);
assertThat(sonarlint.getState()).isEqualTo(State.NEED_UPDATE);
assertThat(sonarlint.getGlobalStorageStatus()).isNotNull();
assertThat(sonarlint.getModuleStorageStatus("foo")).isNull();
try {
sonarlint.allModulesByKey();
fail("Expected exception");
} catch (Exception e) {
assertThat(e).isInstanceOf(GlobalUpdateRequiredException.class).hasMessage("Please update server 'localhost'");
}
try {
sonarlint.getRuleDetails("rule");
fail("Expected exception");
} catch (Exception e) {
assertThat(e).isInstanceOf(GlobalUpdateRequiredException.class).hasMessage("Please update server 'localhost'");
}
try {
sonarlint.analyze(new ConnectedAnalysisConfiguration(null, baseDir.toPath(), temp.newFolder().toPath(), Collections.<ClientInputFile>emptyList(), ImmutableMap.<String, String>of()), mock(IssueListener.class), null, null);
fail("Expected exception");
} catch (Exception e) {
assertThat(e).isInstanceOf(GlobalUpdateRequiredException.class).hasMessage("Please update server 'localhost'");
}
}
use of org.sonarsource.sonarlint.core.client.api.connected.ConnectedAnalysisConfiguration in project sonarlint-intellij by SonarSource.
the class ConnectedSonarLintFacade method analyze.
@Override
protected AnalysisResults analyze(Path baseDir, Path workDir, Collection<ClientInputFile> inputFiles, Map<String, String> props, IssueListener issueListener, ProgressMonitor progressMonitor) {
ConnectedAnalysisConfiguration config = new ConnectedAnalysisConfiguration(moduleKey, baseDir, workDir, inputFiles, props);
console.debug("Starting analysis with configuration:\n" + config.toString());
return sonarlint.analyze(config, issueListener, new ProjectLogOutput(console, projectSettings), progressMonitor);
}
use of org.sonarsource.sonarlint.core.client.api.connected.ConnectedAnalysisConfiguration in project sonarlint-core by SonarSource.
the class ConnectedSonarLintImpl method analyze.
@Override
public void analyze(ConnectedAnalysisReq requestConfig, StreamObserver<org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.Issue> response) {
try {
List<ClientInputFile> files = new LinkedList<>();
List<InputFile> requestFiles = requestConfig.getFileList();
Path baseDir = Paths.get(requestConfig.getBaseDir());
for (InputFile f : requestFiles) {
files.add(new DefaultClientInputFile(baseDir, Paths.get(f.getPath()), f.getIsTest(), Charset.forName(f.getCharset()), f.getUserObject(), trimToNull(f.getLanguage())));
}
ConnectedAnalysisConfiguration config = new ConnectedAnalysisConfiguration(requestConfig.getModuleKey(), baseDir, Paths.get(requestConfig.getWorkDir()), files, requestConfig.getPropertiesMap());
engine.analyze(config, new ProxyIssueListener(response), logOutput, null);
response.onCompleted();
} catch (Exception e) {
LOGGER.error("Error analyzing", e);
response.onError(e);
}
}
use of org.sonarsource.sonarlint.core.client.api.connected.ConnectedAnalysisConfiguration in project sonarlint-core by SonarSource.
the class BrokenStorageMissingPluginMediumTest method require_update.
@Test
public void require_update() throws Exception {
assertThat(sonarlint.getState()).isEqualTo(ConnectedSonarLintEngine.State.NEED_UPDATE);
ClientInputFile inputFile = prepareJavaInputFile();
final List<Issue> issues = new ArrayList<>();
try {
sonarlint.analyze(new ConnectedAnalysisConfiguration(null, baseDir.toPath(), temp.newFolder().toPath(), Arrays.asList(inputFile), ImmutableMap.<String, String>of()), new StoreIssueListener(issues), null, null);
fail("Expected exception");
} catch (Exception e) {
assertThat(e).isExactlyInstanceOf(GlobalUpdateRequiredException.class);
}
}
use of org.sonarsource.sonarlint.core.client.api.connected.ConnectedAnalysisConfiguration in project sonarlint-core by SonarSource.
the class ConnectedEmptyStorageMediumTest method test_no_storage.
@Test
public void test_no_storage() throws Exception {
assertThat(sonarlint.getState()).isEqualTo(State.NEVER_UPDATED);
assertThat(sonarlint.getGlobalStorageStatus()).isNull();
assertThat(sonarlint.getModuleStorageStatus("foo")).isNull();
try {
sonarlint.allModulesByKey();
fail("Expected exception");
} catch (Exception e) {
assertThat(e).isInstanceOf(GlobalUpdateRequiredException.class).hasMessage("Please update server 'localhost'");
}
try {
sonarlint.getRuleDetails("rule");
fail("Expected exception");
} catch (Exception e) {
assertThat(e).isInstanceOf(GlobalUpdateRequiredException.class).hasMessage("Please update server 'localhost'");
}
try {
sonarlint.analyze(new ConnectedAnalysisConfiguration(null, baseDir.toPath(), temp.newFolder().toPath(), Collections.<ClientInputFile>emptyList(), ImmutableMap.<String, String>of()), mock(IssueListener.class), null, null);
fail("Expected exception");
} catch (Exception e) {
assertThat(e).isInstanceOf(GlobalUpdateRequiredException.class).hasMessage("Please update server 'localhost'");
}
}
Aggregations