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
18 changes: 9 additions & 9 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,16 @@ commands +=
"scalafixAll --check" :: "publishLocal" :: s
}

// Shared module that owns the canonical SemanticDB proto schema and the
// associated symbol/builder utilities. Both the Java compiler plugin
// (semanticdb-javac) and the Kotlin compiler plugin (semanticdb-kotlinc)
// depend on it instead of carrying their own divergent copies of the proto.
// Shared module with the SCIP shard utilities (symbol encoder, document
// builder, on-disk writer) consumed by both the Java compiler plugin
// (semanticdb-javac) and the Kotlin compiler plugin (semanticdb-kotlinc).
lazy val semanticdbShared = project
.in(file("semanticdb-shared"))
.settings(
moduleName := "semanticdb-shared",
javaOnlySettings,
(Compile / PB.targets) :=
Seq(PB.gens.java(V.protobuf) -> (Compile / sourceManaged).value),
libraryDependencies += "com.google.protobuf" % "protobuf-java" % V.protobuf
libraryDependencies +=
"org.scip-code" % "scip-java-bindings" % V.scipBindings
)

lazy val gradlePlugin = project
Expand Down Expand Up @@ -329,8 +327,10 @@ lazy val semanticdbKotlinc = project
// classpath via Provided so the assembled fat-jar does not bundle it.
libraryDependencies +=
"org.jetbrains.kotlin" % "kotlin-stdlib" % V.kotlinVersion % Provided,
// The SemanticDB proto schema and the generated Java classes live in
// semanticdbShared; we get them transitively via .dependsOn below.
// SCIP message classes come from semanticdbShared (which depends on
// scip-java-bindings); this adds the Kotlin DSL extensions on top.
libraryDependencies +=
"org.scip-code" % "scip-kotlin-bindings" % V.scipBindings,
// kotlin-compiler-embeddable is supplied by kotlinc at runtime
libraryDependencies +=
"org.jetbrains.kotlin" % "kotlin-compiler-embeddable" % V.kotlinVersion %
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ class GradleBuildTool(index: IndexCommand) extends BuildTool("Gradle", index) {
}

/**
* Diagnose the case where Gradle finished successfully but our SemanticDB
* compiler plugin never produced any `.semanticdb` files. This used to be
* silently rescued by a `-javaagent` fallback; now it surfaces as a clear
* error pointing at the two known causes.
* Diagnose the case where Gradle finished successfully but our SCIP compiler
* plugin never produced any `.scip` shards. This used to be silently rescued
* by a `-javaagent` fallback; now it surfaces as a clear error pointing at
* the two known causes.
*/
private def reportMissingSemanticdbOutput(): Unit = {
if (containsFileWithSuffix(targetroot, ".semanticdb"))
if (containsFileWithSuffix(targetroot, ".scip"))
return
if (!containsFileWithSuffix(index.workingDirectory, ".class"))
// Project produced no compiled JVM output — nothing to index, stay quiet.
Expand All @@ -50,9 +50,9 @@ class GradleBuildTool(index: IndexCommand) extends BuildTool("Gradle", index) {
.app
.reporter
.error(
s"""scip-java: Gradle finished successfully but produced no SemanticDB output in $targetroot.
s"""scip-java: Gradle finished successfully but produced no SCIP shards in $targetroot.
|
|This means our SemanticDB compiler plugin was not attached to one or more JavaCompile tasks. Two known causes:
|This means our SCIP compiler plugin was not attached to one or more JavaCompile tasks. Two known causes:
|
| 1. The 'compileOnly' configuration was already resolved before our init script ran.
| Check the Gradle output above for warnings of the form:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import moped.cli.Command
import moped.cli.CommandParser
import org.scip_code.scip.ToolInfo

@Description("Converts SemanticDB files into a single SCIP index file.")
@Description("Aggregates per-source SCIP shards into a single SCIP index file.")
@Usage("scip-java index-semanticdb [OPTIONS ...] [POSITIONAL ARGUMENTS ...]")
@ExampleUsage(
"scip-java index-semanticdb --out=myindex.scip my/targetroot1 my/targetroot2"
Expand All @@ -26,14 +26,14 @@ import org.scip_code.scip.ToolInfo
final case class IndexSemanticdbCommand(
@Description("The name of the output file.")
output: Path = Paths.get("index.scip"),
@Description("Whether to process the SemanticDB files in parallel")
@Description("Whether to process the SCIP shards in parallel")
parallel: Boolean = true,
@Description(
"Whether to emit parent->child relationships for 'Find references' and 'Find implementations'. " +
"This flag exists as a workaround for the issue https://github.com/sourcegraph/sourcegraph/issues/50927"
)
emitInverseRelationships: Boolean = true,
@Description("Directories that contain SemanticDB files.")
@Description("Directories that contain SCIP shards.")
@PositionalArguments()
targetroot: List[Path] = Nil,
@Description(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,35 @@ case class SnapshotCommand(
attrs: BasicFileAttributes
): FileVisitResult = {
if (scipPattern.matches(file)) {
foundScipFile = true
val index = Index.parseFrom(Files.readAllBytes(file))
val root = URI.create(index.getMetadata.getProjectRoot)
index
.getDocumentsList
.asScala
.foreach { doc =>
val sourcepath = Paths.get(root.resolve(doc.getRelativePath))
val source =
new String(
Files.readAllBytes(sourcepath),
StandardCharsets.UTF_8
// Per-source SCIP shards under META-INF/scip/ carry no Metadata;
// only the aggregated index does. Skip shards so `scip-java
// snapshot <targetroot>` doesn't trip over them.
val projectRoot = index.getMetadata.getProjectRoot
if (!projectRoot.isEmpty) {
foundScipFile = true
val root = URI.create(projectRoot)
index
.getDocumentsList
.asScala
.foreach { doc =>
val sourcepath = Paths.get(
root.resolve(doc.getRelativePath)
)
val document = ScipPrinters.printTextDocument(doc, source)
val snapshotOutput = output.resolve(doc.getRelativePath)
Files.createDirectories(snapshotOutput.getParent)
Files.write(
snapshotOutput,
document.getBytes(StandardCharsets.UTF_8)
)
}
val source =
new String(
Files.readAllBytes(sourcepath),
StandardCharsets.UTF_8
)
val document = ScipPrinters.printTextDocument(doc, source)
val snapshotOutput = output.resolve(doc.getRelativePath)
Files.createDirectories(snapshotOutput.getParent)
Files.write(
snapshotOutput,
document.getBytes(StandardCharsets.UTF_8)
)
}
}
}
super.visitFile(file, attrs)
}
Expand Down

This file was deleted.

Loading
Loading