@@ -137,7 +137,7 @@ final class BloopBspServices(
137137 .requestAsync(endpoints.BuildTarget .run)(p => schedule(run(p)))
138138 .requestAsync(endpoints.BuildTarget .cleanCache)(p => schedule(clean(p)))
139139 .requestAsync(endpoints.BuildTarget .scalaMainClasses)(p => schedule(scalaMainClasses(p)))
140- .requestAsync(ScalaTestClasses .endpoint )(p => schedule(scalaTestClasses(p)))
140+ .requestAsync(endpoints. BuildTarget .scalaTestClasses )(p => schedule(scalaTestClasses(p)))
141141 .requestAsync(endpoints.BuildTarget .dependencySources)(p => schedule(dependencySources(p)))
142142 .requestAsync(endpoints.DebugSession .start)(p => schedule(startDebugSession(p)))
143143 .requestAsync(endpoints.BuildTarget .jvmTestEnvironment)(p => schedule(jvmTestEnvironment(p)))
@@ -316,6 +316,7 @@ final class BloopBspServices(
316316 jvmRunEnvironmentProvider = Some (true ),
317317 canReload = Some (false )
318318 ),
319+ None ,
319320 None
320321 )
321322 )
@@ -567,12 +568,12 @@ final class BloopBspServices(
567568
568569 def scalaTestClasses (
569570 params : bsp.ScalaTestClassesParams
570- ): BspEndpointResponse [ScalaTestClassesResult ] =
571+ ): BspEndpointResponse [bsp. ScalaTestClassesResult ] =
571572 ifInitialized(params.originId) { (state : State , logger : BspServerLogger ) =>
572573 mapToProjects(params.targets, state) match {
573574 case Left (error) =>
574575 logger.error(error)
575- Task .now((state, Right (ScalaTestClassesResult (Nil ))))
576+ Task .now((state, Right (bsp. ScalaTestClassesResult (Nil ))))
576577
577578 case Right (projects) =>
578579 val subTasks = projects.toList.filter(p => TestTask .isTestProject(p._2)).map {
@@ -583,15 +584,15 @@ final class BloopBspServices(
583584 .groupBy(_.framework)
584585 .map {
585586 case (framework, classes) =>
586- ScalaTestClassesItem (id, classes.flatMap(_.classes), Some (framework ))
587+ bsp. ScalaTestClassesItem (id, Some (framework), classes.flatMap(_.classes))
587588 }
588589 .toList
589590 }
590591 item
591592 }
592593
593594 Task .sequence(subTasks).map { items =>
594- val result = ScalaTestClassesResult (items.flatten)
595+ val result = bsp. ScalaTestClassesResult (items.flatten)
595596 (state, Right (result))
596597 }
597598 }
@@ -608,33 +609,43 @@ final class BloopBspServices(
608609 def convert [A : JsonValueCodec ](
609610 f : A => Either [String , Debuggee ]
610611 ): Either [Response .Error , Debuggee ] = {
611- Try (readFromArray[A ](params.data.value)) match {
612- case Failure (error) =>
613- Left (Response .invalidRequest(error.getMessage()))
614- case Success (params) =>
615- f(params) match {
616- case Right (adapter) => Right (adapter)
617- case Left (error) => Left (Response .invalidRequest(error))
612+ params.data match {
613+ case Some (data) =>
614+ Try (readFromArray[A ](data.value)) match {
615+ case Failure (error) =>
616+ Left (Response .invalidRequest(error.getMessage()))
617+ case Success (params) =>
618+ f(params) match {
619+ case Right (adapter) => Right (adapter)
620+ case Left (error) => Left (Response .invalidRequest(error))
621+ }
618622 }
623+ case None =>
624+ Left (Response .invalidRequest(" No debug data available" ))
619625 }
626+
620627 }
621628
622629 params.dataKind match {
623- case bsp.DebugSessionParamsDataKind .ScalaMainClass =>
630+ case Some ( bsp.DebugSessionParamsDataKind .ScalaMainClass ) =>
624631 convert[bsp.ScalaMainClass ](main =>
625632 BloopDebuggeeRunner .forMainClass(projects, main, state, ioScheduler)
626633 )
627- case bsp.DebugSessionParamsDataKind .ScalaTestSuites =>
634+ case Some ( bsp.TestParamsDataKind .ScalaTestSuites ) =>
628635 implicit val codec = JsonCodecMaker .make[List [String ]]
629636 convert[List [String ]](classNames => {
630- val testClasses = ScalaTestSuites (classNames)
637+ val testClasses = bsp.ScalaTestSuites (
638+ classNames.map(className => bsp.ScalaTestSuiteSelection (className, Nil )),
639+ Nil ,
640+ Nil
641+ )
631642 BloopDebuggeeRunner .forTestSuite(projects, testClasses, state, ioScheduler)
632643 })
633- case " scala-test-suites-selection " =>
634- convert[ScalaTestSuites ](testClasses => {
644+ case Some (bsp. TestParamsDataKind . ScalaTestSuitesSelection ) =>
645+ convert[bsp. ScalaTestSuites ](testClasses => {
635646 BloopDebuggeeRunner .forTestSuite(projects, testClasses, state, ioScheduler)
636647 })
637- case bsp.DebugSessionParamsDataKind .ScalaAttachRemote =>
648+ case Some ( bsp.DebugSessionParamsDataKind .ScalaAttachRemote ) =>
638649 Right (BloopDebuggeeRunner .forAttachRemote(state, ioScheduler, projects))
639650 case dataKind => Left (Response .invalidRequest(s " Unsupported data kind: $dataKind" ))
640651 }
@@ -684,7 +695,9 @@ final class BloopBspServices(
684695 .map(_ => backgroundDebugServers -= handler.uri)
685696 .runAsync(ioScheduler)
686697 backgroundDebugServers += handler.uri -> listenAndUnsubscribe
687- Task .now((state, Right (new bsp.DebugSessionAddress (handler.uri.toString))))
698+ Task .now(
699+ (state, Right (new bsp.DebugSessionAddress (bsp.Uri (handler.uri.toString()))))
700+ )
688701
689702 case Left (error) =>
690703 Task .now((state, Left (error)))
@@ -704,7 +717,7 @@ final class BloopBspServices(
704717 List (project),
705718 Nil ,
706719 testFilter,
707- ScalaTestSuites .empty ,
720+ bsp. ScalaTestSuites ( Nil , Nil , Nil ) ,
708721 handler,
709722 mode = RunMode .Normal
710723 )
@@ -804,21 +817,21 @@ final class BloopBspServices(
804817 def findMainClasses (state : State , project : Project ): List [bsp.ScalaMainClass ] =
805818 for {
806819 className <- Tasks .findMainClasses(state, project)
807- } yield bsp.ScalaMainClass (className, Nil , Nil , Nil )
820+ } yield bsp.ScalaMainClass (className, Nil , Nil , None )
808821
809822 ifInitialized(params.originId) { (state : State , logger : BspServerLogger ) =>
810823 mapToProjects(params.targets, state) match {
811824 case Left (error) =>
812825 logger.error(error)
813- Task .now((state, Right (bsp.ScalaMainClassesResult (Nil ))))
826+ Task .now((state, Right (bsp.ScalaMainClassesResult (Nil , params.originId ))))
814827
815828 case Right (projects) =>
816829 val items = for {
817830 (id, project) <- projects.toList
818831 mainClasses = findMainClasses(state, project)
819832 } yield bsp.ScalaMainClassesItem (id, mainClasses)
820833
821- val result = new bsp.ScalaMainClassesResult (items)
834+ val result = new bsp.ScalaMainClassesResult (items, params.originId )
822835 Task .now((state, Right (result)))
823836 }
824837 }
@@ -843,7 +856,7 @@ final class BloopBspServices(
843856 val cmd = Commands .Run (List (project.name))
844857 Interpreter .getMainClass(state, project, cmd.main) match {
845858 case Right (name) =>
846- Right (new bsp.ScalaMainClass (name, cmd.args, Nil , Nil ))
859+ Right (new bsp.ScalaMainClass (name, cmd.args, Nil , None ))
847860 case Left (_) =>
848861 Left (new IllegalStateException (s " Main class for project $project not found " ))
849862 }
@@ -871,16 +884,16 @@ final class BloopBspServices(
871884 project,
872885 config,
873886 cwd,
874- mainClass.`class` ,
887+ mainClass.className ,
875888 mainArgs,
876889 skipJargs = false ,
877- mainClass.environmentVariables,
890+ mainClass.environmentVariables.getOrElse( Nil ) ,
878891 RunMode .Normal
879892 )
880893 case platform @ Platform .Native (config, _, _) =>
881894 val cmd = Commands .Run (List (project.name))
882895 val target = ScalaNativeToolchain .linkTargetFrom(project, config)
883- linkMainWithNative(cmd, project, state, mainClass.`class` , target, platform)
896+ linkMainWithNative(cmd, project, state, mainClass.className , target, platform)
884897 .flatMap { state =>
885898 val args = (target.syntax +: cmd.args).toArray
886899 if (! state.status.isOk) Task .now(state)
@@ -889,7 +902,7 @@ final class BloopBspServices(
889902 case platform @ Platform .Js (config, _, _) =>
890903 val cmd = Commands .Run (List (project.name))
891904 val target = ScalaJsToolchain .linkTargetFrom(project, config)
892- linkMainWithJs(cmd, project, state, mainClass.`class` , target, platform)
905+ linkMainWithJs(cmd, project, state, mainClass.className , target, platform)
893906 .flatMap { state =>
894907 // We use node to run the program (is this a special case?)
895908 val args = (" node" +: target.syntax +: cmd.args).toArray
@@ -1040,10 +1053,10 @@ final class BloopBspServices(
10401053 }
10411054
10421055 val capabilities = bsp.BuildTargetCapabilities (
1043- canCompile = true ,
1044- canTest = true ,
1045- canRun = true ,
1046- canDebug = true
1056+ canCompile = Some ( true ) ,
1057+ canTest = Some ( true ) ,
1058+ canRun = Some ( true ) ,
1059+ canDebug = Some ( true )
10471060 )
10481061 val isJavaOnly = p.scalaInstance.isEmpty
10491062 val languageIds =
@@ -1256,8 +1269,8 @@ final class BloopBspServices(
12561269 bsp.ScalacOptionsItem (
12571270 target = target,
12581271 options = project.scalacOptions.toList,
1259- classpath = classpath,
1260- classDirectory = classesDir
1272+ classpath = classpath.map(_.value) ,
1273+ classDirectory = classesDir.value
12611274 )
12621275 }.toList
12631276 )
@@ -1290,8 +1303,8 @@ final class BloopBspServices(
12901303 bsp.JavacOptionsItem (
12911304 target = target,
12921305 options = project.javacOptions.toList,
1293- classpath = classpath,
1294- classDirectory = classesDir
1306+ classpath = classpath.map(_.value) ,
1307+ classDirectory = classesDir.value
12951308 )
12961309 }.toList
12971310 )
0 commit comments