Skip to content
Merged
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
9 changes: 0 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,6 @@ sbt/BSP/Bloop.

It's best to run tests from the sbt shell, not from the IntelliJ UI.

## Importing the project with Metals

While the cross-language support won't be as rich as it is in IntelliJ,
[Metals](https://scalameta.org/metals/) does offer rich language support for
Scala and basic Java navigation support (thanks to scip-java!). When using
Metals and your editor of choice it's recommended to use sbt as your build
server. This isn't the default with Metals, so you'll want to use the `Metals:
Switch build server` command and choose `sbt`.

## Tests are written in Scala

This codebases uses the Scala library [MUnit](https://scalameta.org/munit/) to
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Java, Scala, and Kotlin indexer for [SCIP](https://github.com/sourcegraph/scip) ![](https://img.shields.io/badge/status-development-green?style=flat)
# Java and Kotlin indexer for [SCIP](https://github.com/sourcegraph/scip) ![](https://img.shields.io/badge/status-development-green?style=flat)

| Documentation | Link |
| -------------------- | ---------------------------------------------------------------------- |
Expand Down
52 changes: 4 additions & 48 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@ lazy val V =
val moped = "0.2.0"
val gradle = "7.0"
val scala213 = "2.13.13"
val scala3 = "3.3.3"
val metals = "1.2.2"
val scalameta = "4.9.3"
val requests = "0.8.0"
val minimalMillVersion = "0.10.0"
val millScipVersion = "0.3.6"
val kotlinVersion = "2.2.0"
val kotest = "4.6.3"
val kctfork = "0.7.1"
Expand Down Expand Up @@ -117,20 +113,8 @@ lazy val gradlePlugin = project
sbtVersion,
scalaVersion,
"javacModuleOptions" -> javacModuleOptions,
"semanticdbScalacVersions" ->
com
.sourcegraph
.sbtsourcegraph
.Versions
.cachedSemanticdbVersionsByScalaVersion,
"sbtSourcegraphVersion" ->
com.sourcegraph.sbtsourcegraph.BuildInfo.version,
"semanticdbVersion" -> V.scalameta,
"mtagsVersion" -> V.metals,
"scala213" -> V.scala213,
"scala3" -> V.scala3,
"minimalMillVersion" -> V.minimalMillVersion,
"millScipVersion" -> V.millScipVersion
"scala213" -> V.scala213
)
)
.enablePlugins(BuildInfoPlugin)
Expand Down Expand Up @@ -241,31 +225,17 @@ lazy val cli = project
sbtVersion,
scalaVersion,
"javacModuleOptions" -> javacModuleOptions,
"semanticdbScalacVersions" ->
com
.sourcegraph
.sbtsourcegraph
.Versions
.cachedSemanticdbVersionsByScalaVersion,
"sbtSourcegraphVersion" ->
com.sourcegraph.sbtsourcegraph.BuildInfo.version,
"semanticdbVersion" -> V.scalameta,
"mtagsVersion" -> V.metals,
"scala213" -> V.scala213,
"scala3" -> V.scala3,
"minimalMillVersion" -> V.minimalMillVersion,
"millScipVersion" -> V.millScipVersion
"scala213" -> V.scala213
),
buildInfoPackage := "com.sourcegraph.scip_java",
libraryDependencies ++=
List(
"io.get-coursier" %% "coursier" % V.coursier,
"io.get-coursier" %% "coursier-jvm" % V.coursier,
"org.scalameta" % "mtags-interfaces" % V.metals,
"org.scala-lang.modules" %% "scala-xml" % V.scalaXml,
"com.lihaoyi" %% "requests" % V.requests,
"org.scalameta" %% "moped" % V.moped,
"org.scalameta" %% "ascii-graphs" % "0.1.2",
"org.jetbrains.kotlin" % "kotlin-compiler-embeddable" % V.kotlinVersion,
"org.jetbrains.kotlin" % "kotlin-scripting-common" % V.kotlinVersion,
"org.jetbrains.kotlin" % "kotlin-scripting-jvm" % V.kotlinVersion,
Expand Down Expand Up @@ -627,15 +597,6 @@ lazy val minimized21 = project
.dependsOn(agent, javacPlugin)
.disablePlugins(JavaFormatterPlugin)

lazy val minimizedScala = project
.in(file("tests/minimized-scala"))
.settings(
(publish / skip) := true,
semanticdbOptions ++=
List("-P:semanticdb:text:on", "-P:semanticdb:synthetics:on")
)
.dependsOn(minimized)

lazy val unit = project
.in(file("tests/unit"))
.settings(
Expand All @@ -649,11 +610,7 @@ lazy val unit = project
"sourceroot" -> (ThisBuild / baseDirectory).value,
"minimizedJavaSourceDirectory" -> minimizedSourceDirectory,
"minimizedJavaTargetroot" ->
(minimized / Compile / semanticdbTargetRoot).value,
"minimizedScalaSourceDirectory" ->
(minimizedScala / Compile / sourceDirectory).value / "scala",
"minimizedScalaTargetroot" ->
(minimizedScala / Compile / semanticdbTargetRoot).value
(minimized / Compile / semanticdbTargetRoot).value
),
buildInfoPackage := "tests"
)
Expand Down Expand Up @@ -694,7 +651,7 @@ lazy val snapshots = project
),
buildInfoPackage := "tests.snapshots"
)
.dependsOn(minimizedScala, unit)
.dependsOn(unit)
.enablePlugins(BuildInfoPlugin)

lazy val bench = project
Expand Down Expand Up @@ -730,7 +687,6 @@ val testSettings = List(
libraryDependencies ++=
List(
"org.scalameta" %% "munit" % "0.7.29",
"org.scalameta" %% "mtags" % V.metals cross CrossVersion.full,
"org.scalameta" %% "moped-testkit" % V.moped,
"org.scalameta" %% "scalameta" % V.scalameta,
"io.get-coursier" %% "coursier" % V.coursier,
Expand Down
13 changes: 4 additions & 9 deletions docs/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ There are several benefits to implementing scip-java as a compiler plugin:
### Why SemanticDB?

SemanticDB is Protobuf schema for information about symbols and types in Java
programs, Scala programs and other languages. There are several benefits to
using SemanticDB as an intermediary representation for SCIP:
programs and other languages. There are several benefits to using SemanticDB as
an intermediary representation for SCIP:

- **Simplicity**: It's easy to translate a single Java source file into a single
SemanticDB file inside a compiler plugin. It's more complicated to produce
Expand All @@ -39,14 +39,9 @@ using SemanticDB as an intermediary representation for SCIP:
- **Performance**: SemanticDB is fast to write and read. Each compilation unit
can be processed independently to keep memory usage low. The final conversion
from SemanticDB to SCIP can be safely parallelized.
- **Cross-language**: SemanticDB has a
[spec](https://scalameta.org/docs/semanticdb/specification.html) for Java and
Scala enabling cross-language navigation in hybrid Java/Scala codebases.
- **Cross-repository**: Compiler plugins have access to both source code and the
classpath (compiled bytecode of upstream dependencies). SemanticDB has been
designed so that it's also possible to generate spec-compliant symbols from
the classpath alone (no source code) and from the syntax tree of an individual
source file (no classpath). This flexibility allows the
[Metals](https://scalameta.org/metals/) language server to index codebases
from a variety of different inputs, and will be helpful for scip-java in the
future to unblock cross-repository navigation.
source file (no classpath). This flexibility will be helpful for scip-java in
the future to unblock cross-repository navigation.
91 changes: 21 additions & 70 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: Getting started

By following the instructions on this page, you should be able to generate a
[SCIP](https://github.com/sourcegraph/scip) index of your Java codebase using
Gradle, Maven, sbt, or Bazel. See
Gradle, Maven, or Bazel. See
[Supported build tools](#supported-build-tools) for an overview of other build
tools that we're planning to support in the future.

Expand Down Expand Up @@ -136,16 +136,9 @@ If you're using Maven.
</dependency>
```

If you're using sbt.

```scala
scalaVersion := "@SCALA_VERSION@" // Only Scala 2.13 is supported.
libraryDependencies += "com.sourcegraph" %% "scip-java" % "@STABLE_VERSION@"
```

## Run `scip-java index`

> The `index` command is only supported for Gradle, Maven and sbt. See
> The `index` command is only supported for Gradle and Maven. See
> [Supported build tools](#supported-build-tools) for more details about other
> build tools.

Expand All @@ -156,18 +149,16 @@ This command should automatically infer the structure of your codebase and
configure your build tool to generate SCIP.

```sh
# At the root of a Gradle, Maven or sbt codebase.
# At the root of a Gradle or Maven codebase.
$ scip-java index
...
info: /path/to/index.scip
```

| Build tool | Default command |
| ---------- | ------------------------------------------------------------------------------- |
| Gradle | `clean compileTestJava compileTestScala compileTestKotlin compileTestKotlinJvm` |
| Maven | `--batch-mode clean verify -DskipTests` |
| sbt | `sourcegraphEnable sourcegraphScip` (via sbt-sourcegraph plugin) |
| Mill | `io.kipp.mill.scip.Scip/generate` (via mill-scip plugin) |
| Build tool | Default command |
| ---------- | ---------------------------------------------------------- |
| Gradle | `clean compileTestJava compileTestKotlin compileTestKotlinJvm` |
| Maven | `--batch-mode clean verify -DskipTests` |

Customize the build command by passing additional arguments after
`scip-java index --`.
Expand Down Expand Up @@ -208,11 +199,10 @@ com.sourcegraph.scip_java.ScipJava.printHelp(Console.out)

## Supported programming languages

| Programming language | Gradle | Maven | sbt | Mill | Tracking issue |
| -------------------- | ------ | ----- | --- | ---- | ----------------------------------------------------------- |
| Java | ✅ | ✅ | ✅ | ✅ | |
| Scala | ✅ | ❌ | ✅ | ✅ | [#302](https://github.com/sourcegraph/scip-java/issues/302) |
| Kotlin | ✅ | ❌ | n/a | n/a | |
| Programming language | Gradle | Maven | Tracking issue |
| -------------------- | ------ | ----- | -------------- |
| Java | ✅ | ✅ | |
| Kotlin | ✅ | ❌ | |

### Java

Expand All @@ -239,26 +229,11 @@ For Java 17 and newer versions, the following JVM options are required:
--add-exports jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
```

### Scala

Scala version support should always match the Scala versions that are supported
by [Metals](https://scalameta.org/metals), the Scala language server.

| Scala version | Goto definition | Find references | Hover |
| ------------- | --------------- | --------------- | ----- |
| Scala 2.11.x | ❌ | ❌ | ❌ |
| Scala 2.12.x | ❌ | ❌ | ❌ |
| Scala 2.13.x | ✅ | ✅ | ✅ |
| Scala 3.x | ✅ | ✅ | ❌ |

> Scala.js and Scala Native have equal support as Scala on the JVM.

### Kotlin

The Kotlin support in scip-java is less mature compared to the Java and Scala
support. Don't hesitate to report issues at
https://github.com/sourcegraph/scip-java if you encounter issues using the
Kotlin support.
The Kotlin support in scip-java is less mature compared to the Java support.
Don't hesitate to report issues at https://github.com/sourcegraph/scip-java if
you encounter issues using the Kotlin support.

## Supported build tools

Expand All @@ -271,15 +246,13 @@ tools may require [manual configuration](manual-configuration.md).
Please open an issue if your build tool is not listed in the table below. Feel
free to subscribe to the tracking issues to receive updates on your build tool.

| Build tool | Java | Scala | Kotlin | Tracking issue |
| ---------- | ---- | ----- | ------ | -------------------------------------------------------------------------------- |
| Maven | ✅ | ❌ | ❌ | |
| Gradle | ✅ | ✅ | ✅ | |
| sbt | ✅ | ✅ | n/a | |
| Ant | ❌ | ❌ | ❌ | [sourcegraph/scip-java#305](https://github.com/sourcegraph/scip-java/issues/305) |
| Bazel | ✅ | ✅ | ❌ | |
| Buck | ❌ | ❌ | ❌ | [sourcegraph/scip-java#99](https://github.com/sourcegraph/scip-java/issues/99) |
| Mill | ✅ | ✅ | ❌ |
| Build tool | Java | Kotlin | Tracking issue |
| ---------- | ---- | ------ | -------------------------------------------------------------------------------- |
| Maven | ✅ | ❌ | |
| Gradle | ✅ | ✅ | |
| Ant | ❌ | ❌ | [sourcegraph/scip-java#305](https://github.com/sourcegraph/scip-java/issues/305) |
| Bazel | ✅ | ❌ | |
| Buck | ❌ | ❌ | [sourcegraph/scip-java#99](https://github.com/sourcegraph/scip-java/issues/99) |

**✅**: automatic indexing is fully supported. Please report a bug if the
`scip-java index` command does not work on your codebase.
Expand Down Expand Up @@ -310,7 +283,6 @@ The following Gradle integrations are not yet supported:
| ----------- | --------- | -------------------------------------------------------------------------------- |
| Android | ❌ | [sourcegraph/scip-java#177](https://github.com/sourcegraph/scip-java/issues/177) |
| Kotlin | ✅ | |
| Scala | ✅ | |

### Maven

Expand All @@ -322,29 +294,8 @@ The following Maven integrations are not yet supported:

| Integration | Supported | Tracking issue |
| ------------------- | --------- | -------------------------------------------------------------------------------- |
| scala-maven-plugin | ❌ | [sourcegraph/scip-java#301](https://github.com/sourcegraph/scip-java/issues/301) |
| scalor-maven-plugin | ❌ | [sourcegraph/scip-java#301](https://github.com/sourcegraph/scip-java/issues/301) |
| kotlin-maven-plugin | ❌ | [sourcegraph/scip-java#304](https://github.com/sourcegraph/scip-java/issues/304) |

### sbt

The `scip-java index` build should be able to automatically index most sbt
projects, with the following caveats:

| Integration | Supported | Recommendation |
| ------------- | --------- | ----------------------- |
| sbt <v0.13.17 | ❌ | Upgrade to sbt v0.13.17 |

### Mill

The `scip-java index` build should be able to automatically index most Mill
projects, with the following caveats:

| Integration | Supported | Recommendation |
| ------------- | ------------------- | ------------------------------------------- |
| Mill <v0.10.0 | ❌ | Upgrade to Mill >= v0.10.0 |
| Mill <v0.10.6 | Only supports Scala | Upgrade to Mill >= v0.10.6 for Java support |

### Bazel

There are two approaches to index Bazel/Java codebases: automatic and manual.
Expand Down
18 changes: 0 additions & 18 deletions docs/manual-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ If you're using Maven.
</dependency>
```

If you're using sbt.

```scala
libraryDependencies += "com.sourcegraph" % "semanticdb-javac" % "@STABLE_VERSION@"
```

## Step 2: Enable `-Xplugin:semanticdb` compiler option

Add `-Xplugin:semanticdb` to your compiler options to enable the SemanticDB
Expand Down Expand Up @@ -108,17 +102,6 @@ If you're using Maven.
</project>
```

If you're using sbt.

```scala
javaHome := Some(...) // Must be configured to fork the compiler.
Compile / javacOptions += {
val sourceroot = (ThisBuild / baseDirectory).value
val targetroot = sourceroot / "target" / "semanticdb-targetroot"
s"-Xplugin:semanticdb -sourceroot:$sourceroot -targetroot:$targetroot"
}
```

## Step 3: Compile the codebase

Compile all source files in the codebase once the compiler setting has been
Expand All @@ -127,7 +110,6 @@ examples:

- Gradle: `./gradlew clean compileJava compileTestJava`
- Maven: `mvn clean verify -DskipTests`
- sbt: `sbt clean test:compile`
- Bazel: `bazel build //...`

If everything went well, you should have a lot of `*.semanticdb` files in the
Expand Down
1 change: 0 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
jdk
jq
(maven.override ({ jdk_headless = jdk; }))
(mill.override ({ jre = jdk; }))
nixfmt
nodejs
(sbt.override ({ jre = jdk; }))
Expand Down
4 changes: 0 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.5")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.14.3")
addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.6")
addSbtPlugin("com.sourcegraph" % "sbt-sourcegraph" % "0.4.4")
addSbtPlugin("com.lightbend.sbt" % "sbt-java-formatter" % "0.6.1")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0")
Expand All @@ -15,8 +14,5 @@ addSbtPlugin("com.github.sbt.junit" % "sbt-jupiter-interface" % "0.15.1")
// [error] (plugin / Compile / compileIncremental) java.lang.NoClassDefFoundError: com/sun/tools/javac/code/Symbol
addSbtPlugin("org.scala-debugger" % "sbt-jdi-tools" % "1.1.1")

libraryDependencies ++=
List("com.thesamet.scalapb" %% "compilerplugin" % "0.11.11")

ThisBuild / libraryDependencySchemes ++=
Seq("org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always)
Loading
Loading