Skip to content

Commit

Permalink
bugfix: Don't add debugging if using sbt 2 and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed Dec 18, 2024
1 parent c114b89 commit 21b387e
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,26 @@ object SbtBuildTool {
def writeSbtMetalsPlugins(projectRoot: AbsolutePath): Boolean = {
val mainMeta = projectRoot.resolve("project")
val metaMeta = projectRoot.resolve("project").resolve("project")
val writtenPlugin =
writePlugins(mainMeta, metalsPluginDetails, debugAdapterPluginDetails)
val writtenMeta =
writePlugins(metaMeta, metalsPluginDetails, jdiToolsPluginDetails)
writtenPlugin || writtenMeta

val isSbt2 =
SbtBuildTool.loadVersion(projectRoot).exists(_.startsWith("2."))
if (isSbt2) {
val writtenPlugin = writePlugins(mainMeta, metalsPluginDetails)
val writtenMeta = writePlugins(
metaMeta,
metalsPluginDetails,
)
writtenMeta || writtenPlugin
} else {
val writtenPlugin = writePlugins(
mainMeta,
metalsPluginDetails,
debugAdapterPluginDetails,
)
val writtenMeta =
writePlugins(metaMeta, metalsPluginDetails, jdiToolsPluginDetails)
writtenMeta || writtenPlugin
}
}

private case class PluginDetails(
Expand Down
41 changes: 41 additions & 0 deletions tests/slow/src/test/scala/tests/sbt/SbtServerSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,47 @@ class SbtServerSuite
}
}

test("sbt-2.0.0") {
cleanWorkspace()
client.importBuildChanges = ImportBuildChanges.yes
for {
_ <- initialize(
s"""|/project/build.properties
|sbt.version=2.0.0-M3
|/build.sbt
|
|scalaVersion := "$scalaVersion"
|val a = project.in(file("a"))
|val b = project.in(file("b"))
|/a/src/main/scala/A.scala
|
|object A{
| val foo = 1
| foo + foo
|}
|""".stripMargin
)
_ <- server.server.indexingPromise.future
references <- server.references("a/src/main/scala/A.scala", "foo")
_ = assertEmpty(client.workspaceDiagnostics)
_ = assertNoDiff(
references,
"""|a/src/main/scala/A.scala:3:7: info: reference
| val foo = 1
| ^^^
|a/src/main/scala/A.scala:4:3: info: reference
| foo + foo
| ^^^
|a/src/main/scala/A.scala:4:9: info: reference
| foo + foo
| ^^^
|""".stripMargin,
)
_ = assertEmpty(client.workspaceShowMessages)
} yield ()

}

test("reload") {
cleanWorkspace()
client.importBuildChanges = ImportBuildChanges.yes
Expand Down

0 comments on commit 21b387e

Please sign in to comment.