Skip to content

Commit

Permalink
Moved reflection logic into BspServerStarter companion
Browse files Browse the repository at this point in the history
  • Loading branch information
lefou committed Jan 13, 2023
1 parent e9d8781 commit 8d031b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 1 addition & 5 deletions main/src/mill/MillMain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,7 @@ object MillMain {
stderr.println("Trying to load BSP server...")
val bspServerFuture = Future {
try {
// We cannot link this class directly, as it would give us a circular dependency
val bspClass = MillMain.this.getClass.getClassLoader.loadClass("mill.bsp.BspServerStarterImpl")
val method = bspClass.getMethod("get")
val serverStarter = method.invoke(null).asInstanceOf[BspServerStarter]
serverStarter.startBspServer(
BspServerStarter().startBspServer(
initialEvaluator = None,
outStream = MillMain.initialSystemStreams.out,
errStream = System.err,
Expand Down
9 changes: 9 additions & 0 deletions main/src/mill/main/BspServerStarter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,12 @@ trait BspServerStarter {
serverHandle: Option[Promise[BspServerHandle]] = None
): BspServerResult
}

object BspServerStarter {
def apply(): BspServerStarter = {
// We cannot link this class directly, as it would give us a circular dependency
val bspClass = getClass().getClassLoader.loadClass("mill.bsp.BspServerStarterImpl")
val method = bspClass.getMethod("get")
method.invoke(null).asInstanceOf[BspServerStarter]
}
}

0 comments on commit 8d031b6

Please sign in to comment.