Skip to content

Commit

Permalink
bugfix: Add output classes directory to classpath for PC
Browse files Browse the repository at this point in the history
It was there already for bloop and sbt, but not for mill. Because of this, presentation compiler didn't see symbols from workspace.
  • Loading branch information
jkciesluk authored and tgodzik committed Nov 13, 2023
1 parent 2c0873c commit 08867f9
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1015,8 +1015,12 @@ object MetalsEnrichments
.map(_.stripPrefix(flag))
}

def classpath: List[String] =
item.getClasspath.asScala.toList
def classpath: List[String] = {
val outputClasses = item.getClassDirectory
val classes = item.getClasspath.asScala.toList
if (classes.contains(outputClasses)) classes
else outputClasses :: classes
}

def jarClasspath: List[AbsolutePath] =
classpath
Expand Down
54 changes: 54 additions & 0 deletions tests/slow/src/test/scala/tests/mill/MillServerSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,58 @@ class MillServerSuite
}
}
}

test(s"presentation-compiler") {
def millBspConfig = workspace.resolve(".bsp/mill-bsp.json")
writeLayout(
s"""
|/.mill-version
|$supportedBspVersion
|/build.sc
|import mill._, scalalib._
|object foo extends ScalaModule {
| def scalaVersion = "${V.scala213}"
|}
|/foo/src/Main.scala
|package foo
|
|import foo.A
|object Main extends App {
| println(A.msg)
|}
|
|/foo/src/A.scala
|package foo
|
|object A {
| def msg = "Hello"
|}
|""".stripMargin
)
for {
_ <- server.initialize()
_ <- server.initialized()
_ = assertNoDiff(
client.workspaceMessageRequests,
importBuildMessage,
)
_ = client.messageRequests.clear() // restart
_ = assert(!millBspConfig.exists)
_ = server.server.buildServerPromise = Promise()
_ <- server.executeCommand(ServerCommands.GenerateBspConfig)
_ <- server.server.buildServerPromise.future
_ = assert(millBspConfig.exists)
_ = server.assertBuildServerConnection()
_ <- server.didOpen("foo/src/Main.scala")
_ <- server.assertHoverAtLine(
"foo/src/Main.scala",
"println(A.m@@sg)",
"""|```scala
|def msg: String
|```
|""".stripMargin,
)

} yield {}
}
}

0 comments on commit 08867f9

Please sign in to comment.