use of org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleList.Module.Builder in project sonarlint-core by SonarSource.
the class ModuleListDownloader method fetchModulesListAfter6dot3.
private void fetchModulesListAfter6dot3(Path dest, ProgressWrapper progress) {
ModuleList.Builder moduleListBuilder = ModuleList.newBuilder();
Builder moduleBuilder = ModuleList.Module.newBuilder();
String baseUrl = "api/components/search.protobuf?qualifiers=TRK,BRC";
if (wsClient.getOrganizationKey() != null) {
baseUrl += "&organization=" + StringUtils.urlEncode(wsClient.getOrganizationKey());
}
SonarLintWsClient.getPaginated(wsClient, baseUrl, WsComponents.SearchWsResponse::parseFrom, WsComponents.SearchWsResponse::getPaging, WsComponents.SearchWsResponse::getComponentsList, module -> {
moduleBuilder.clear();
moduleListBuilder.putModulesByKey(module.getKey(), moduleBuilder.setProjectKey(module.getProject()).setKey(module.getKey()).setName(module.getName()).setQu(module.getQualifier()).build());
}, progress);
ProtobufUtil.writeToFile(moduleListBuilder.build(), dest.resolve(StoragePaths.MODULE_LIST_PB));
}
use of org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleList.Module.Builder in project sonarlint-core by SonarSource.
the class ModuleListDownloader method fetchModulesListBefore6dot3.
private void fetchModulesListBefore6dot3(Path dest) {
try (WsResponse response = wsClient.get("api/projects/index?format=json&subprojects=true")) {
try (Reader contentReader = response.contentReader()) {
DefaultModule[] results = new Gson().fromJson(contentReader, DefaultModule[].class);
ModuleList.Builder moduleListBuilder = ModuleList.newBuilder();
Builder moduleBuilder = ModuleList.Module.newBuilder();
for (DefaultModule module : results) {
moduleBuilder.clear();
moduleListBuilder.putModulesByKey(module.k, moduleBuilder.setKey(module.k).setName(module.nm).setQu(module.qu).build());
}
ProtobufUtil.writeToFile(moduleListBuilder.build(), dest.resolve(StoragePaths.MODULE_LIST_PB));
} catch (IOException e) {
throw new IllegalStateException("Failed to load module list", e);
}
}
}
Aggregations