Skip to content

Commit 076c596

Browse files
committed
Drop SemanticDB from Kotlin compiler plug-in; emit SCIP shards only
Stacked on the Java SCIP-shard drop. semanticdb-kotlinc now bypasses the SemanticDB protobuf step entirely: the FIR visitor feeds ScipTextDocumentBuilder directly, the plug-in writes per-source *.scip shards under META-INF/scip/, and the legacy SemanticDB writers, schema, shared SemanticdbDocumentBuilder, and protobuf codegen are removed. The aggregator's SemanticDB fallback and the --use-scip-shards opt-in flag are also dropped — SCIP-shard aggregation is now the only path.
1 parent 9771e45 commit 076c596

45 files changed

Lines changed: 151 additions & 5333 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ If you'd rather install tools manually, you'll need at least:
3131

3232
These are the main components of the project.
3333

34-
- `semanticdb-javac/src/main/java`: the Java compiler plugin that creates
35-
SemanticDB files.
34+
- `semanticdb-javac/src/main/java`: the Java compiler plugin that emits
35+
SCIP shard files.
3636
- `tests/minimized`: minimized Java source files that reproduce interesting test
3737
cases.
3838
- `tests/unit`: fast running unit tests that are helpful for local edit-and-test

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ lazy val semanticdbKotlincMinimized = project
531531
Def.sequential(
532532
Compile / compile,
533533
(cli / Compile / runMain).toTask(
534-
s" $mainCls index-semanticdb --no-emit-inverse-relationships --use-scip-shards --cwd $srcRoot --output $scipOut $tgtRoot"
534+
s" $mainCls index-semanticdb --no-emit-inverse-relationships --cwd $srcRoot --output $scipOut $tgtRoot"
535535
),
536536
(cli / Compile / runMain).toTask(
537537
s" $mainCls snapshot --cwd $srcRoot --output $snapDir ${file(

docs/design.md

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ title: Design
55

66
This project is implemented as a
77
[Java compiler plugin](https://docs.oracle.com/en/java/javase/11/docs/api/jdk.compiler/com/sun/source/util/Plugin.html)
8-
that generates one
9-
[SemanticDB](https://scalameta.org/docs/semanticdb/specification.html) file for
10-
every `*.java` source file. After compilation completes, the SemanticDB files
11-
are processed to produce SCIP.
8+
that emits one [SCIP](https://github.com/sourcegraph/scip) shard file for every
9+
`*.java` source file. After compilation completes, the per-file SCIP shards are
10+
aggregated into a single SCIP index.
1211

1312
### Why Java compiler plugin?
1413

@@ -24,24 +23,3 @@ There are several benefits to implementing scip-java as a compiler plugin:
2423
tool, we minimize the risk of diverging from the CI build environment such as
2524
installed system dependencies, custom compiler options and custom annotation
2625
processors.
27-
28-
### Why SemanticDB?
29-
30-
SemanticDB is Protobuf schema for information about symbols and types in Java
31-
programs and other languages. There are several benefits to using SemanticDB as
32-
an intermediary representation for SCIP:
33-
34-
- **Simplicity**: It's easy to translate a single Java source file into a single
35-
SemanticDB file inside a compiler plugin. It's more complicated to produce
36-
SCIP because compiler plugins does not have access to a project-wide context,
37-
which is necessary to produce accurate definitions and hovers in multi-module
38-
projects with external library dependencies.
39-
- **Performance**: SemanticDB is fast to write and read. Each compilation unit
40-
can be processed independently to keep memory usage low. The final conversion
41-
from SemanticDB to SCIP can be safely parallelized.
42-
- **Cross-repository**: Compiler plugins have access to both source code and the
43-
classpath (compiled bytecode of upstream dependencies). SemanticDB has been
44-
designed so that it's also possible to generate spec-compliant symbols from
45-
the classpath alone (no source code) and from the syntax tree of an individual
46-
source file (no classpath). This flexibility will be helpful for scip-java in
47-
the future to unblock cross-repository navigation.

docs/getting-started.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,10 @@ Next, run the following command to generate the SCIP index (`index.scip`).
351351
```
352352
bazel run @scip_java//scip-semanticdb:bazel -- --sourceroot $PWD
353353
354-
# (optional) Validate that SemanticDB files were generated.
354+
# (optional) Validate that SCIP shard files were generated.
355355
# The command below works for the `examples/bazel-example` directory in the sourcegraph/scip-java repository.
356-
❯ jar tf bazel-bin/src/main/java/example/libexample.jar | grep semanticdb$
357-
META-INF/semanticdb/src/main/java/example/Example.java.semanticdb
356+
❯ jar tf bazel-bin/src/main/java/example/libexample.jar | grep scip$
357+
META-INF/scip/src/main/java/example/Example.java.scip
358358
```
359359

360360
Finally, run the following commands to upload the SCIP index to Sourcegraph.

docs/manual-configuration.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ fails.
1212

1313
Indexing a codebase consists of two independent phases:
1414

15-
- Compile the codebase with the SemanticDB compiler plugin.
16-
- Generate SCIP index from SemanticDB files.
17-
18-
![A three stage pipeline that starts with a list of Java sources, creates a list of SemanticDB files that then become a single SCIP index.](assets/semanticdb-javac-pipeline.svg)
15+
- Compile the codebase with the SemanticDB compiler plugin, which writes one
16+
SCIP shard per Java source file.
17+
- Aggregate the SCIP shards into a single SCIP index.
1918

2019
The first phase can be complicated to configure and it can take a while to run.
2120
The second phase is quite simple to configure and it usually runs very fast.
@@ -63,7 +62,7 @@ compiler plugin. To do this you need to explicitly configure two directories:
6362
It's important that all of the source files that should be index live under
6463
this directory.
6564
- `-targetroot:PATH`: the absolute path to the directory where to generate
66-
SemanticDB file. This directory can be anywhere on your file system.
65+
SCIP shard files. This directory can be anywhere on your file system.
6766
Alternatively, pass in `-targetroot:javac-classes-directory` for the plugin to
6867
automatically use the `javac` output directory.
6968

@@ -112,13 +111,13 @@ examples:
112111
- Maven: `mvn clean verify -DskipTests`
113112
- Bazel: `bazel build //...`
114113

115-
If everything went well, you should have a lot of `*.semanticdb` files in the
114+
If everything went well, you should have a lot of `*.scip` shard files in the
116115
targetroot directory.
117116

118117
```
119118
❯ find $TARGETROOT -type f
120-
build/semanticdb-targetroot/META-INF/semanticdb/j11/src/test/java/example/ExampleTest.java.semanticdb
121-
build/semanticdb-targetroot/META-INF/semanticdb/j11/src/main/java/example/Example.java.semanticdb
119+
build/semanticdb-targetroot/META-INF/scip/j11/src/test/java/example/ExampleTest.java.scip
120+
build/semanticdb-targetroot/META-INF/scip/j11/src/main/java/example/Example.java.scip
122121
...
123122
```
124123

@@ -198,13 +197,13 @@ Which allows you to invoke it by simply running `mvn sourcegraph:sourcegraphDepe
198197
Cross-repository navigation is a feature that allows "goto definition" and "find
199198
references" to show results from multiple repositories.
200199

201-
## Step 5: Generate SCIP index from SemanticDB files
200+
## Step 5: Aggregate SCIP shards into a single SCIP index
202201

203202
First, install the `scip-java` command-line tool according to the instructions
204203
in the [getting started guide](getting-started.md).
205204

206-
Next, run the `scip-java index-semanticdb` command to convert SemanticDB files
207-
into SCIP.
205+
Next, run the `scip-java index-semanticdb` command to aggregate the per-file
206+
SCIP shards into a single SCIP index.
208207

209208
```sh
210209
❯ scip-java index-semanticdb $TARGETROOT

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class ScipBuildTool(index: IndexCommand) extends BuildTool("SCIP", index) {
206206
.app
207207
.reporter
208208
.info(
209-
"Some SemanticDB files got generated even if there were compile errors. " +
209+
"Some SCIP shard files got generated even if there were compile errors. " +
210210
"In most cases, this means that scip-java managed to index everything " +
211211
"except the locations that had compile errors and you can ignore the compile errors."
212212
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ case class IndexCommand(
2929
@Description("The path where to generate the SCIP index.")
3030
output: Path = Paths.get("index.scip"),
3131
@Description(
32-
"The directory where to generate SemanticDB files. " +
32+
"The directory where to generate SCIP shard files. " +
3333
"Defaults to a build-specific path. " +
3434
"For example, the default value for Gradle is 'build/semanticdb-targetroot' and for Maven it's 'target/semanticdb-targetroot'"
3535
)

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

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import com.sourcegraph.io.AbsolutePath
1010
import com.sourcegraph.scip_java.BuildInfo
1111
import com.sourcegraph.scip_java.buildtools.ClasspathEntry
1212
import com.sourcegraph.scip_semanticdb.ConsoleScipSemanticdbReporter
13-
import com.sourcegraph.scip_semanticdb.ScipSemanticdb
1413
import com.sourcegraph.scip_semanticdb.ScipSemanticdbOptions
1514
import com.sourcegraph.scip_semanticdb.ScipShardAggregator
1615
import moped.annotations._
@@ -21,7 +20,7 @@ import org.scip_code.scip.ToolInfo
2120
import ujson.Arr
2221
import ujson.Obj
2322

24-
@Description("Converts SemanticDB files into a single SCIP index file.")
23+
@Description("Aggregates SCIP shard files into a single SCIP index file.")
2524
@Usage("scip-java index-semanticdb [OPTIONS ...] [POSITIONAL ARGUMENTS ...]")
2625
@ExampleUsage(
2726
"scip-java index-semanticdb --out=myindex.scip my/targetroot1 my/targetroot2"
@@ -30,10 +29,10 @@ import ujson.Obj
3029
final case class IndexSemanticdbCommand(
3130
@Description("The name of the output file.")
3231
output: Path = Paths.get("index.scip"),
33-
@Description("Whether to process the SemanticDB files in parallel")
32+
@Description("Whether to process the SCIP shard files in parallel")
3433
parallel: Boolean = true,
3534
@Description(
36-
"Whether to infer the location of SemanticDB files based as produced by Bazel"
35+
"Whether to infer the location of SCIP shard files based as produced by Bazel"
3736
)
3837
bazel: Boolean = true,
3938
@Description(
@@ -44,7 +43,7 @@ final case class IndexSemanticdbCommand(
4443
@Description("URL to a PackageHub instance")
4544
@Hidden
4645
packagehub: Option[String] = None,
47-
@Description("Directories that contain SemanticDB files.")
46+
@Description("Directories that contain SCIP shard files.")
4847
@PositionalArguments()
4948
targetroot: List[Path] = Nil,
5049
@Description(
@@ -60,11 +59,6 @@ final case class IndexSemanticdbCommand(
6059
"Maven->Maven or Gradle->Gradle projects because those build tools compile sources to classfiles inside directories."
6160
)
6261
allowExportingGlobalSymbolsFromDirectoryEntries: Boolean = true,
63-
@Description(
64-
"If true, aggregate *.scip shards under META-INF/scip/ instead of *.semanticdb files. " +
65-
"Pass --use-scip-shards=false to fall back to the SemanticDB-based aggregator."
66-
)
67-
useScipShards: Boolean = true,
6862
@Inline()
6963
app: Application = Application.default
7064
) extends Command {
@@ -102,10 +96,7 @@ final case class IndexSemanticdbCommand(
10296
allowEmptyIndex,
10397
allowExportingGlobalSymbolsFromDirectoryEntries
10498
)
105-
if (useScipShards)
106-
ScipShardAggregator.run(options)
107-
else
108-
ScipSemanticdb.run(options)
99+
ScipShardAggregator.run(options)
109100
postPackages(packages)
110101
if (!app.reporter.hasErrors()) {
111102
app.info(options.output.toString)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public boolean hasErrors() {
6565
/* allowEmptyIndex */ true,
6666
/* indexDirectoryEntries */ false // because Bazel only compiles to jar files.
6767
);
68-
ScipSemanticdb.run(scipOptions);
68+
ScipShardAggregator.run(scipOptions);
6969

7070
if (!scipOptions.reporter.hasErrors()) {
7171
System.out.println("done: " + scipOptions.output);

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

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

0 commit comments

Comments
 (0)