in src/main/java/com/uber/scip/aggregator/scip/ScipBuilder.java [57:99]
public void buildScip(BuildOptions buildOptions) throws IOException {
List<MavenPackage> mavenPackages =
collectMavenPackagesFromClasspath(buildOptions.getClasspathString());
// Reverse it make sure that map will have the latest version of the package
// @see com.sourcegraph.scip_semanticdb.PackageTable
Collections.reverse(mavenPackages);
ScipSemanticdbOptions scipOptions =
new ScipSemanticdbOptions(
buildOptions.getTargetRoots(),
buildOptions.getOutputPath(),
buildOptions.getSourceRoot(),
this.reporter,
LsifToolInfo.newBuilder().setName("scip-java").setVersion("HEAD").build(),
"java",
ScipOutputFormat.TYPED_PROTOBUF,
true, // parallel,
mavenPackages,
/* buildKind */ "",
/* emitInverseRelationships */ true,
/* allowEmptyIndex */ true,
/* indexDirectoryEntries */ true);
ScipSemanticdb semanticdb =
scipSemanticdbFactory.create(
new UberScipWriter(scipOptions, buildOptions, this.diagnosticCollector), scipOptions);
try {
// Hate this, but there not much we can do.
// We either have to use reflection or read index into memory after it gets written by
// original writer.
// In the long run we can create PR upstream. But for now, this is the best we can do.
Method runMethod = ScipSemanticdb.class.getDeclaredMethod("run");
runMethod.setAccessible(true);
runMethod.invoke(semanticdb);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
logger.error("Failed to invoke run method via reflection", e);
throw new RuntimeException("Failed to build SCIP index", e);
}
if (scipOptions.reporter.hasErrors()) {
logger.debug("SCIP index generation failed");
}
}