Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.sourcegraph.scip_java.commands.IndexCommand
import com.sourcegraph.scip_java.commands.IndexDependencyCommand
import com.sourcegraph.scip_java.commands.IndexSemanticdbCommand
import com.sourcegraph.scip_java.commands.SnapshotCommand
import com.sourcegraph.scip_java.commands.SnapshotLsifCommand
import moped.cli.Application
import moped.cli.CommandParser
import moped.commands.HelpCommand
Expand All @@ -23,8 +22,7 @@ object ScipJava {
CommandParser[IndexCommand],
CommandParser[IndexSemanticdbCommand],
CommandParser[IndexDependencyCommand],
CommandParser[SnapshotCommand],
CommandParser[SnapshotLsifCommand]
CommandParser[SnapshotCommand]
)
)
def main(args: Array[String]): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ object BuildTool {
def generateScipFromTargetroot(
generateSemanticdbResult: CommandResult,
targetroot: Path,
index: IndexCommand,
buildKind: String = ""
index: IndexCommand
): Int = {
if (!Files.isDirectory(targetroot)) {
generateSemanticdbResult.exitCode
Expand All @@ -62,7 +61,6 @@ object BuildTool {
output = index.finalOutput,
targetroot = List(targetroot),
packagehub = index.packagehub,
buildKind = buildKind,
app = index.app
)
.run()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ class ScipBuildTool(index: IndexCommand) extends BuildTool("SCIP", index) {
BuildTool.generateScipFromTargetroot(
generateSemanticdb(),
index.finalTargetroot(defaultTargetroot),
index,
buildKind
index
)
}

Expand All @@ -117,7 +116,6 @@ class ScipBuildTool(index: IndexCommand) extends BuildTool("SCIP", index) {
ScipBuildTool
.ConfigFileNames
.map(name => index.workingDirectory.resolve(name))
private def buildKind: String = parsedConfig.fold(_.kind, _ => "")
private def generateSemanticdb(): CommandResult = {
parsedConfig match {
case ValueResult(value) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import java.util.concurrent.TimeUnit

import scala.jdk.CollectionConverters._

import com.sourcegraph.Scip
import com.sourcegraph.io.AbsolutePath
import com.sourcegraph.lsif_protocol.LsifToolInfo
import com.sourcegraph.scip_java.BuildInfo
import com.sourcegraph.scip_java.buildtools.ClasspathEntry
import com.sourcegraph.scip_semanticdb.ConsoleScipSemanticdbReporter
Expand Down Expand Up @@ -47,8 +47,6 @@ final case class IndexSemanticdbCommand(
@Description("Directories that contain SemanticDB files.")
@PositionalArguments()
targetroot: List[Path] = Nil,
@Description("The kind of this build, one of: empty string, jdk, maven")
buildKind: String = "",
@Description(
"If true, don't report an error when no documents have been indexed. " +
"The resulting SCIP index will silently be empty instead."
Expand Down Expand Up @@ -79,7 +77,7 @@ final case class IndexSemanticdbCommand(
if (format == ScipOutputFormat.UNKNOWN) {
app.error(
s"unknown output format for filename '$outputFilename'. " +
s"Supported file extension are `*.scip`, `*scip '"
s"Supported file extensions are `*.scip` and `*.scip.ndjson`"
)
return 1
}
Expand All @@ -97,16 +95,15 @@ final case class IndexSemanticdbCommand(
AbsolutePath.of(output, sourceroot),
sourceroot,
reporter,
LsifToolInfo
Scip
.ToolInfo
.newBuilder()
.setName("scip-java")
.setVersion(BuildInfo.version)
.build(),
"java",
format,
parallel,
packages.map(_.toPackageInformation).asJava,
buildKind,
emitInverseRelationships,
allowEmptyIndex,
allowExportingGlobalSymbolsFromDirectoryEntries
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.sourcegraph.scip_semanticdb;

import com.sourcegraph.scip_java.Bazelbuild;
import com.sourcegraph.lsif_protocol.LsifToolInfo;
import com.sourcegraph.Scip;

import java.io.*;
import java.nio.file.FileSystems;
Expand Down Expand Up @@ -58,12 +58,10 @@ public boolean hasErrors() {
options.output,
options.sourceroot,
reporter,
LsifToolInfo.newBuilder().setName("scip-java").setVersion("HEAD").build(),
"java",
Scip.ToolInfo.newBuilder().setName("scip-java").setVersion("HEAD").build(),
ScipOutputFormat.TYPED_PROTOBUF,
options.parallel,
mavenPackages,
/* buildKind */ "",
/* emitInverseRelationships */ true,
/* allowEmptyIndex */ true,
/* indexDirectoryEntries */ false // because Bazel only compiles to jar files.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,25 @@
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.regex.Pattern;

public class PackageTable implements Function<Package, Integer> {
public class PackageTable {

private final Map<String, Package> byClassfile = new HashMap<>();
private final Set<String> cachedJdkSymbols = new HashSet<>();
private final Map<Package, Integer> scip = new ConcurrentHashMap<>();
private final JavaVersion javaVersion;
private final ScipWriter writer;
private final boolean indexDirectoryEntries;

private static final PathMatcher CLASS_PATTERN =
FileSystems.getDefault().getPathMatcher("glob:**.class");
private static final PathMatcher JAR_PATTERN =
FileSystems.getDefault().getPathMatcher("glob:**.jar");

public PackageTable(ScipSemanticdbOptions options, ScipWriter writer) throws IOException {
this.writer = writer;
public PackageTable(ScipSemanticdbOptions options) throws IOException {
this.javaVersion = new JavaVersion();
this.indexDirectoryEntries = options.allowExportingGlobalSymbolsFromDirectoryEntries;
// NOTE: it's important that we index the JDK before maven packages. Some maven packages
Expand All @@ -46,11 +39,6 @@ public PackageTable(ScipSemanticdbOptions options, ScipWriter writer) throws IOE
}
}

public void writeMonikerPackage(int monikerId, Package pkg) {
int pkgId = scip.computeIfAbsent(pkg, this);
writer.emitPackageInformationEdge(monikerId, pkgId);
}

public Optional<Package> packageForSymbol(String symbol) {
return SymbolDescriptor.toplevel(symbol)
.flatMap(
Expand Down Expand Up @@ -148,9 +136,4 @@ private void indexBootstrapClasspath() throws IOException {
}
}
}

@Override
public Integer apply(Package pkg) {
return writer.emitpackageinformationVertex(pkg);
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
package com.sourcegraph.scip_semanticdb;

/**
* Whether to generate index.scip (JSON) or index.scip-protobuf (Protobuf).
*
* <p>The Protobuf format is experimental and currently only exists as a proof-of-concept.
*/
/** Whether to generate index.scip (Protobuf) or index.scip.ndjson (newline-delimited JSON). */
public enum ScipOutputFormat {
GRAPH_NDJSON,
GRAPH_PROTOBUF,
TYPED_PROTOBUF,
TYPED_NDJSON,
UNKNOWN;

public boolean isTyped() {
return this == TYPED_NDJSON || this == TYPED_PROTOBUF;
}

public boolean isNewlineDelimitedJSON() {
return this == GRAPH_NDJSON || this == TYPED_NDJSON;
return this == TYPED_NDJSON;
}

public static ScipOutputFormat fromFilename(String name) {
if (name.endsWith(".lsif")) return GRAPH_NDJSON;
if (name.endsWith(".lsif-protobuf")) return GRAPH_PROTOBUF;
if (name.endsWith(".scip")) return TYPED_PROTOBUF;
if (name.endsWith(".scip.ndjson")) return TYPED_NDJSON;
return UNKNOWN;
Expand Down
Loading