Skip to content

Commit 7cbce23

Browse files
committed
Simplify codebase after LSIF removal
- Remove unused fields from ScipSemanticdbOptions: language, buildKind, format - Remove unused methods from ScipOutputFormat: isTyped(), isNewlineDelimitedJSON() - Remove unused imports from PackageTable: Iterator, Pattern - Remove unused symbols field from ScipTextDocument - Delete unused ScipProcessingException class - Simplify ScipOutputStream to direct writes without concurrent buffering - Update all call sites in IndexSemanticdbCommand, BazelBuildTool, BuildTool, ScipBuildTool
1 parent ec3d217 commit 7cbce23

File tree

11 files changed

+10
-80
lines changed

11 files changed

+10
-80
lines changed

scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/BuildTool.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ object BuildTool {
4646
def generateScipFromTargetroot(
4747
generateSemanticdbResult: CommandResult,
4848
targetroot: Path,
49-
index: IndexCommand,
50-
buildKind: String = ""
49+
index: IndexCommand
5150
): Int = {
5251
if (!Files.isDirectory(targetroot)) {
5352
generateSemanticdbResult.exitCode
@@ -62,7 +61,6 @@ object BuildTool {
6261
output = index.finalOutput,
6362
targetroot = List(targetroot),
6463
packagehub = index.packagehub,
65-
buildKind = buildKind,
6664
app = index.app
6765
)
6866
.run()

scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/ScipBuildTool.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ class ScipBuildTool(index: IndexCommand) extends BuildTool("SCIP", index) {
105105
BuildTool.generateScipFromTargetroot(
106106
generateSemanticdb(),
107107
index.finalTargetroot(defaultTargetroot),
108-
index,
109-
buildKind
108+
index
110109
)
111110
}
112111

@@ -117,7 +116,6 @@ class ScipBuildTool(index: IndexCommand) extends BuildTool("SCIP", index) {
117116
ScipBuildTool
118117
.ConfigFileNames
119118
.map(name => index.workingDirectory.resolve(name))
120-
private def buildKind: String = parsedConfig.fold(_.kind, _ => "")
121119
private def generateSemanticdb(): CommandResult = {
122120
parsedConfig match {
123121
case ValueResult(value) =>

scip-java/src/main/scala/com/sourcegraph/scip_java/commands/IndexSemanticdbCommand.scala

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import com.sourcegraph.io.AbsolutePath
1111
import com.sourcegraph.scip_java.BuildInfo
1212
import com.sourcegraph.scip_java.buildtools.ClasspathEntry
1313
import com.sourcegraph.scip_semanticdb.ConsoleScipSemanticdbReporter
14-
import com.sourcegraph.scip_semanticdb.ScipOutputFormat
1514
import com.sourcegraph.scip_semanticdb.ScipSemanticdb
1615
import com.sourcegraph.scip_semanticdb.ScipSemanticdbOptions
1716
import moped.annotations._
@@ -47,8 +46,6 @@ final case class IndexSemanticdbCommand(
4746
@Description("Directories that contain SemanticDB files.")
4847
@PositionalArguments()
4948
targetroot: List[Path] = Nil,
50-
@Description("The kind of this build, one of: empty string, jdk, maven")
51-
buildKind: String = "",
5249
@Description(
5350
"If true, don't report an error when no documents have been indexed. " +
5451
"The resulting SCIP index will silently be empty instead."
@@ -74,15 +71,6 @@ final case class IndexSemanticdbCommand(
7471

7572
def run(): Int = {
7673
val reporter = new ConsoleScipSemanticdbReporter(app)
77-
val outputFilename = output.getFileName.toString
78-
val format = ScipOutputFormat.fromFilename(outputFilename)
79-
if (format == ScipOutputFormat.UNKNOWN) {
80-
app.error(
81-
s"unknown output format for filename '$outputFilename'. " +
82-
s"Supported file extensions are `*.scip` and `*.scip.ndjson`"
83-
)
84-
return 1
85-
}
8674
val packages =
8775
absoluteTargetroots
8876
.iterator
@@ -103,11 +91,8 @@ final case class IndexSemanticdbCommand(
10391
.setName("scip-java")
10492
.setVersion(BuildInfo.version)
10593
.build(),
106-
"java",
107-
format,
10894
parallel,
10995
packages.map(_.toPackageInformation).asJava,
110-
buildKind,
11196
emitInverseRelationships,
11297
allowEmptyIndex,
11398
allowExportingGlobalSymbolsFromDirectoryEntries

scip-semanticdb/src/main/java/com/sourcegraph/scip_semanticdb/BazelBuildTool.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,8 @@ public boolean hasErrors() {
5959
options.sourceroot,
6060
reporter,
6161
Scip.ToolInfo.newBuilder().setName("scip-java").setVersion("HEAD").build(),
62-
"java",
63-
ScipOutputFormat.TYPED_PROTOBUF,
6462
options.parallel,
6563
mavenPackages,
66-
/* buildKind */ "",
6764
/* emitInverseRelationships */ true,
6865
/* allowEmptyIndex */ true,
6966
/* indexDirectoryEntries */ false // because Bazel only compiles to jar files.

scip-semanticdb/src/main/java/com/sourcegraph/scip_semanticdb/PackageTable.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@
88
import java.util.Enumeration;
99
import java.util.HashMap;
1010
import java.util.HashSet;
11-
import java.util.Iterator;
1211
import java.util.Map;
1312
import java.util.Optional;
1413
import java.util.Set;
15-
1614
import java.util.jar.JarEntry;
1715
import java.util.jar.JarFile;
18-
import java.util.regex.Pattern;
1916

2017
public class PackageTable {
2118

scip-semanticdb/src/main/java/com/sourcegraph/scip_semanticdb/ScipOutputFormat.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ public enum ScipOutputFormat {
66
TYPED_NDJSON,
77
UNKNOWN;
88

9-
public boolean isTyped() {
10-
return this != UNKNOWN;
11-
}
12-
13-
public boolean isNewlineDelimitedJSON() {
14-
return this == TYPED_NDJSON;
15-
}
16-
179
public static ScipOutputFormat fromFilename(String name) {
1810
if (name.endsWith(".scip")) return TYPED_PROTOBUF;
1911
if (name.endsWith(".scip.ndjson")) return TYPED_NDJSON;

scip-semanticdb/src/main/java/com/sourcegraph/scip_semanticdb/ScipOutputStream.java

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,21 @@
22

33
import java.io.IOException;
44
import java.io.OutputStream;
5-
import java.util.concurrent.ConcurrentLinkedDeque;
6-
import java.util.concurrent.atomic.AtomicBoolean;
75

86
/** Low-level methods to write raw SCIP bytes into the output stream. */
97
public class ScipOutputStream {
108
private final OutputStream out;
11-
private final ConcurrentLinkedDeque<byte[]> buffer;
12-
private final AtomicBoolean isFlushing;
139

1410
public ScipOutputStream(OutputStream out) {
1511
this.out = out;
16-
this.buffer = new ConcurrentLinkedDeque<>();
17-
this.isFlushing = new AtomicBoolean(false);
1812
}
1913

20-
public void write(byte[] bytes) {
14+
public void write(byte[] bytes) throws IOException {
2115
if (bytes.length == 0) return;
22-
buffer.add(bytes);
16+
out.write(bytes);
2317
}
2418

2519
public void flush() throws IOException {
26-
if (isFlushing.compareAndSet(false, true)) {
27-
byte[] bytes = buffer.poll();
28-
while (bytes != null) {
29-
out.write(bytes);
30-
bytes = buffer.poll();
31-
}
32-
out.flush();
33-
isFlushing.set(false);
34-
}
20+
out.flush();
3521
}
3622
}

scip-semanticdb/src/main/java/com/sourcegraph/scip_semanticdb/ScipProcessingException.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

scip-semanticdb/src/main/java/com/sourcegraph/scip_semanticdb/ScipSemanticdbOptions.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@ public class ScipSemanticdbOptions {
1212
public final Path sourceroot;
1313
public final ScipSemanticdbReporter reporter;
1414
public final Scip.ToolInfo toolInfo;
15-
public final String language;
16-
public final ScipOutputFormat format;
1715
public final boolean parallel;
1816
public final List<MavenPackage> packages;
19-
public final String buildKind;
2017
public final boolean emitInverseRelationships;
2118
public final boolean allowEmptyIndex;
2219
public final boolean allowExportingGlobalSymbolsFromDirectoryEntries;
@@ -27,11 +24,8 @@ public ScipSemanticdbOptions(
2724
Path sourceroot,
2825
ScipSemanticdbReporter reporter,
2926
Scip.ToolInfo toolInfo,
30-
String language,
31-
ScipOutputFormat format,
3227
boolean parallel,
3328
List<MavenPackage> packages,
34-
String buildKind,
3529
boolean emitInverseRelationships,
3630
boolean allowEmptyIndex,
3731
boolean allowExportingGlobalSymbolsFromDirectoryEntries) {
@@ -40,11 +34,8 @@ public ScipSemanticdbOptions(
4034
this.sourceroot = sourceroot;
4135
this.reporter = reporter;
4236
this.toolInfo = toolInfo;
43-
this.language = language;
44-
this.format = format;
4537
this.parallel = parallel;
4638
this.packages = packages;
47-
this.buildKind = buildKind;
4839
this.emitInverseRelationships = emitInverseRelationships;
4940
this.allowEmptyIndex = allowEmptyIndex;
5041
this.allowExportingGlobalSymbolsFromDirectoryEntries =

scip-semanticdb/src/main/java/com/sourcegraph/scip_semanticdb/ScipTextDocument.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
public class ScipTextDocument {
1111
public final Path semanticdbPath;
1212
public Semanticdb.TextDocument semanticdb;
13-
public final Map<String, Semanticdb.SymbolInformation> symbols;
1413
// Map from symbols that have a definition occurrence to the list of symbols that have
1514
// `is_definition` relationships to that symbol.
1615
// This map is used to add `is_reference` relationships between all symbols in the list so that
@@ -23,7 +22,6 @@ public class ScipTextDocument {
2322
public ScipTextDocument(
2423
Path semanticdbPath, Semanticdb.TextDocument semanticdb, Path sourceroot) {
2524
this.semanticdbPath = semanticdbPath;
26-
this.symbols = new HashMap<>();
2725
String uri = sourceroot.resolve(semanticdb.getUri()).toUri().toString();
2826
setSemanticdb(Semanticdb.TextDocument.newBuilder(semanticdb).setUri(uri).build());
2927
}
@@ -72,9 +70,6 @@ void visitIdTree(Semanticdb.IdTree tree) {
7270

7371
private void setSemanticdb(Semanticdb.TextDocument semanticdb) {
7472
this.semanticdb = manifestOccurrencesForSyntheticSymbols(semanticdb);
75-
for (Semanticdb.SymbolInformation info : semanticdb.getSymbolsList()) {
76-
symbols.put(info.getSymbol(), info);
77-
}
7873
}
7974

8075
public Semanticdb.TextDocument manifestOccurrencesForSyntheticSymbols(

0 commit comments

Comments
 (0)