use of org.sonarsource.sonarlint.core.client.api.connected.SonarAnalyzer in project sonarlint-core by SonarSource.
the class ConnectedSonarLintEngineImpl method update.
@Override
public UpdateResult update(ServerConfiguration serverConfig, @Nullable ProgressMonitor monitor) {
checkNotNull(serverConfig);
setLogging(null);
return withRwLock(() -> {
stop(false);
changeState(State.UPDATING);
List<SonarAnalyzer> analyzers;
try {
analyzers = runInConnectedContainer(serverConfig, container -> container.update(new ProgressWrapper(monitor)));
} finally {
start();
}
return new UpdateResult(getHandler().getGlobalStorageStatus(), analyzers);
});
}
use of org.sonarsource.sonarlint.core.client.api.connected.SonarAnalyzer in project sonarlint-core by SonarSource.
the class GlobalStorageUpdateChecker method checkForUpdate.
public StorageUpdateCheckResult checkForUpdate(ProgressWrapper progress) {
DefaultStorageUpdateCheckResult result = new DefaultStorageUpdateCheckResult();
progress.setProgressAndCheckCancel("Checking server version and status", 0.1f);
ServerInfos serverStatus = statusChecker.checkVersionAndStatus();
// Currently with don't check server version change since it is unlikely to have impact on SL
progress.setProgressAndCheckCancel("Checking global properties", 0.3f);
globalSettingsUpdateChecker.checkForUpdates(serverStatus.getVersion(), result);
progress.setProgressAndCheckCancel("Checking plugins", 0.5f);
List<SonarAnalyzer> pluginList = pluginListDownloader.downloadPluginList(serverStatus.getVersion());
pluginsUpdateChecker.checkForUpdates(result, pluginList);
progress.setProgressAndCheckCancel("Checking quality profiles", 0.7f);
qualityProfilesUpdateChecker.checkForUpdates(result);
progress.setProgressAndCheckCancel("Done", 1.0f);
return result;
}
use of org.sonarsource.sonarlint.core.client.api.connected.SonarAnalyzer in project sonarlint-core by SonarSource.
the class GlobalStorageUpdateExecutor method update.
public List<SonarAnalyzer> update(ProgressWrapper progress) {
Path temp = tempFolder.newDir().toPath();
try {
progress.setProgressAndCheckCancel("Checking server version and status", 0.1f);
ServerInfos serverStatus = statusChecker.checkVersionAndStatus();
progress.setProgressAndCheckCancel("Fetching list of analyzers", 0.12f);
List<SonarAnalyzer> analyzers = pluginListDownloader.downloadPluginList(serverStatus.getVersion());
ProtobufUtil.writeToFile(serverStatus, temp.resolve(StoragePaths.SERVER_INFO_PB));
progress.setProgressAndCheckCancel("Fetching global properties", 0.15f);
globalSettingsDownloader.fetchGlobalSettingsTo(serverStatus.getVersion(), temp);
progress.setProgressAndCheckCancel("Fetching analyzers", 0.25f);
pluginReferenceDownloader.fetchPluginsTo(temp, analyzers);
progress.setProgressAndCheckCancel("Fetching rules", 0.4f);
rulesDownloader.fetchRulesTo(temp, progress.subProgress(0.4f, 0.6f, "Fetching rules"));
progress.setProgressAndCheckCancel("Fetching quality profiles", 0.6f);
qualityProfilesDownloader.fetchQualityProfilesTo(temp);
progress.setProgressAndCheckCancel("Fetching list of modules", 0.8f);
moduleListDownloader.fetchModulesListTo(temp, serverStatus.getVersion(), progress.subProgress(0.8f, 1.0f, "Fetching list of modules"));
progress.startNonCancelableSection();
progress.setProgressAndCheckCancel("Finalizing...", 1.0f);
StorageStatus storageStatus = StorageStatus.newBuilder().setStorageVersion(StoragePaths.STORAGE_VERSION).setClientUserAgent(wsClient.getUserAgent()).setSonarlintCoreVersion(VersionUtils.getLibraryVersion()).setUpdateTimestamp(new Date().getTime()).build();
ProtobufUtil.writeToFile(storageStatus, temp.resolve(StoragePaths.STORAGE_STATUS_PB));
Path dest = storageManager.getGlobalStorageRoot();
FileUtils.deleteRecursively(dest);
FileUtils.mkdirs(dest.getParent());
FileUtils.moveDir(temp, dest);
return analyzers;
} catch (RuntimeException e) {
try {
FileUtils.deleteRecursively(temp);
} catch (RuntimeException ignore) {
// ignore because we want to throw original exception
}
throw e;
}
}
use of org.sonarsource.sonarlint.core.client.api.connected.SonarAnalyzer in project sonarlint-intellij by SonarSource.
the class ServerUpdateTask method run.
public void run(@NotNull ProgressIndicator indicator) {
indicator.setText("Fetching data...");
try {
TaskProgressMonitor monitor = new TaskProgressMonitor(indicator);
ServerConfiguration serverConfiguration = SonarLintUtils.getServerConfiguration(server);
if (!onlyModules) {
UpdateResult updateResult = engine.update(serverConfiguration, monitor);
Collection<SonarAnalyzer> tooOld = updateResult.analyzers().stream().filter(SonarAnalyzer::sonarlintCompatible).filter(ServerUpdateTask::tooOld).collect(Collectors.toList());
if (!tooOld.isEmpty()) {
ApplicationManager.getApplication().invokeAndWait(() -> Messages.showWarningDialog(buildMinimumVersionFailMessage(tooOld), "Analyzers Not Loaded"), ModalityState.any());
}
log.log("Server binding '" + server.getName() + "' updated", LogOutput.Level.INFO);
}
updateModules(serverConfiguration, monitor);
} catch (CanceledException e) {
LOGGER.info("Update of server '" + server.getName() + "' was cancelled");
log.log("Update of server '" + server.getName() + "' was cancelled", LogOutput.Level.INFO);
} catch (Exception e) {
LOGGER.info("Error updating from server '" + server.getName() + "'", e);
final String msg = (e.getMessage() != null) ? e.getMessage() : ("Failed to update binding for server configuration '" + server.getName() + "'");
ApplicationManager.getApplication().invokeAndWait(new RunnableAdapter() {
@Override
public void doRun() {
Messages.showErrorDialog((Project) null, msg, "Update Failed");
}
}, ModalityState.any());
}
}
use of org.sonarsource.sonarlint.core.client.api.connected.SonarAnalyzer in project sonarlint-core by SonarSource.
the class PluginListDownloader method downloadPluginListBefore66.
public List<SonarAnalyzer> downloadPluginListBefore66(Version serverVersion) {
List<SonarAnalyzer> analyzers = new LinkedList<>();
boolean compatibleFlagPresent = serverVersion.compareToIgnoreQualifier(Version.create("6.0")) >= 0;
String responseStr;
try (WsResponse response = wsClient.get(WS_PATH_LTS)) {
responseStr = response.content();
}
Scanner scanner = new Scanner(responseStr);
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
String[] fields = StringUtils.split(line, ",");
String[] nameAndHash = StringUtils.split(fields[fields.length - 1], "|");
String key = fields[0];
String filename = nameAndHash[0];
String hash = nameAndHash[1];
String version = VersionUtils.getJarVersion(filename);
String minVersion = pluginVersionChecker.getMinimumVersion(key);
boolean sonarlintCompatible = PluginCacheLoader.isWhitelisted(key) || !compatibleFlagPresent || "true".equals(fields[1]);
DefaultSonarAnalyzer analyzer = new DefaultSonarAnalyzer(key, filename, hash, version, sonarlintCompatible, minVersion);
analyzers.add(analyzer);
}
scanner.close();
return analyzers;
}
Aggregations