@@ -137,7 +137,7 @@ final class BloopBspServices(
137
137
.requestAsync(endpoints.BuildTarget .run)(p => schedule(run(p)))
138
138
.requestAsync(endpoints.BuildTarget .cleanCache)(p => schedule(clean(p)))
139
139
.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)))
141
141
.requestAsync(endpoints.BuildTarget .dependencySources)(p => schedule(dependencySources(p)))
142
142
.requestAsync(endpoints.DebugSession .start)(p => schedule(startDebugSession(p)))
143
143
.requestAsync(endpoints.BuildTarget .jvmTestEnvironment)(p => schedule(jvmTestEnvironment(p)))
@@ -316,6 +316,7 @@ final class BloopBspServices(
316
316
jvmRunEnvironmentProvider = Some (true ),
317
317
canReload = Some (false )
318
318
),
319
+ None ,
319
320
None
320
321
)
321
322
)
@@ -567,12 +568,12 @@ final class BloopBspServices(
567
568
568
569
def scalaTestClasses (
569
570
params : bsp.ScalaTestClassesParams
570
- ): BspEndpointResponse [ScalaTestClassesResult ] =
571
+ ): BspEndpointResponse [bsp. ScalaTestClassesResult ] =
571
572
ifInitialized(params.originId) { (state : State , logger : BspServerLogger ) =>
572
573
mapToProjects(params.targets, state) match {
573
574
case Left (error) =>
574
575
logger.error(error)
575
- Task .now((state, Right (ScalaTestClassesResult (Nil ))))
576
+ Task .now((state, Right (bsp. ScalaTestClassesResult (Nil ))))
576
577
577
578
case Right (projects) =>
578
579
val subTasks = projects.toList.filter(p => TestTask .isTestProject(p._2)).map {
@@ -583,15 +584,15 @@ final class BloopBspServices(
583
584
.groupBy(_.framework)
584
585
.map {
585
586
case (framework, classes) =>
586
- ScalaTestClassesItem (id, classes.flatMap(_.classes), Some (framework ))
587
+ bsp. ScalaTestClassesItem (id, Some (framework), classes.flatMap(_.classes))
587
588
}
588
589
.toList
589
590
}
590
591
item
591
592
}
592
593
593
594
Task .sequence(subTasks).map { items =>
594
- val result = ScalaTestClassesResult (items.flatten)
595
+ val result = bsp. ScalaTestClassesResult (items.flatten)
595
596
(state, Right (result))
596
597
}
597
598
}
@@ -608,33 +609,43 @@ final class BloopBspServices(
608
609
def convert [A : JsonValueCodec ](
609
610
f : A => Either [String , Debuggee ]
610
611
): 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
+ }
618
622
}
623
+ case None =>
624
+ Left (Response .invalidRequest(" No debug data available" ))
619
625
}
626
+
620
627
}
621
628
622
629
params.dataKind match {
623
- case bsp.DebugSessionParamsDataKind .ScalaMainClass =>
630
+ case Some ( bsp.DebugSessionParamsDataKind .ScalaMainClass ) =>
624
631
convert[bsp.ScalaMainClass ](main =>
625
632
BloopDebuggeeRunner .forMainClass(projects, main, state, ioScheduler)
626
633
)
627
- case bsp.DebugSessionParamsDataKind .ScalaTestSuites =>
634
+ case Some ( bsp.TestParamsDataKind .ScalaTestSuites ) =>
628
635
implicit val codec = JsonCodecMaker .make[List [String ]]
629
636
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
+ )
631
642
BloopDebuggeeRunner .forTestSuite(projects, testClasses, state, ioScheduler)
632
643
})
633
- case " scala-test-suites-selection " =>
634
- convert[ScalaTestSuites ](testClasses => {
644
+ case Some (bsp. TestParamsDataKind . ScalaTestSuitesSelection ) =>
645
+ convert[bsp. ScalaTestSuites ](testClasses => {
635
646
BloopDebuggeeRunner .forTestSuite(projects, testClasses, state, ioScheduler)
636
647
})
637
- case bsp.DebugSessionParamsDataKind .ScalaAttachRemote =>
648
+ case Some ( bsp.DebugSessionParamsDataKind .ScalaAttachRemote ) =>
638
649
Right (BloopDebuggeeRunner .forAttachRemote(state, ioScheduler, projects))
639
650
case dataKind => Left (Response .invalidRequest(s " Unsupported data kind: $dataKind" ))
640
651
}
@@ -684,7 +695,9 @@ final class BloopBspServices(
684
695
.map(_ => backgroundDebugServers -= handler.uri)
685
696
.runAsync(ioScheduler)
686
697
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
+ )
688
701
689
702
case Left (error) =>
690
703
Task .now((state, Left (error)))
@@ -704,7 +717,7 @@ final class BloopBspServices(
704
717
List (project),
705
718
Nil ,
706
719
testFilter,
707
- ScalaTestSuites .empty ,
720
+ bsp. ScalaTestSuites ( Nil , Nil , Nil ) ,
708
721
handler,
709
722
mode = RunMode .Normal
710
723
)
@@ -804,21 +817,21 @@ final class BloopBspServices(
804
817
def findMainClasses (state : State , project : Project ): List [bsp.ScalaMainClass ] =
805
818
for {
806
819
className <- Tasks .findMainClasses(state, project)
807
- } yield bsp.ScalaMainClass (className, Nil , Nil , Nil )
820
+ } yield bsp.ScalaMainClass (className, Nil , Nil , None )
808
821
809
822
ifInitialized(params.originId) { (state : State , logger : BspServerLogger ) =>
810
823
mapToProjects(params.targets, state) match {
811
824
case Left (error) =>
812
825
logger.error(error)
813
- Task .now((state, Right (bsp.ScalaMainClassesResult (Nil ))))
826
+ Task .now((state, Right (bsp.ScalaMainClassesResult (Nil , params.originId ))))
814
827
815
828
case Right (projects) =>
816
829
val items = for {
817
830
(id, project) <- projects.toList
818
831
mainClasses = findMainClasses(state, project)
819
832
} yield bsp.ScalaMainClassesItem (id, mainClasses)
820
833
821
- val result = new bsp.ScalaMainClassesResult (items)
834
+ val result = new bsp.ScalaMainClassesResult (items, params.originId )
822
835
Task .now((state, Right (result)))
823
836
}
824
837
}
@@ -843,7 +856,7 @@ final class BloopBspServices(
843
856
val cmd = Commands .Run (List (project.name))
844
857
Interpreter .getMainClass(state, project, cmd.main) match {
845
858
case Right (name) =>
846
- Right (new bsp.ScalaMainClass (name, cmd.args, Nil , Nil ))
859
+ Right (new bsp.ScalaMainClass (name, cmd.args, Nil , None ))
847
860
case Left (_) =>
848
861
Left (new IllegalStateException (s " Main class for project $project not found " ))
849
862
}
@@ -871,16 +884,16 @@ final class BloopBspServices(
871
884
project,
872
885
config,
873
886
cwd,
874
- mainClass.`class` ,
887
+ mainClass.className ,
875
888
mainArgs,
876
889
skipJargs = false ,
877
- mainClass.environmentVariables,
890
+ mainClass.environmentVariables.getOrElse( Nil ) ,
878
891
RunMode .Normal
879
892
)
880
893
case platform @ Platform .Native (config, _, _) =>
881
894
val cmd = Commands .Run (List (project.name))
882
895
val target = ScalaNativeToolchain .linkTargetFrom(project, config)
883
- linkMainWithNative(cmd, project, state, mainClass.`class` , target, platform)
896
+ linkMainWithNative(cmd, project, state, mainClass.className , target, platform)
884
897
.flatMap { state =>
885
898
val args = (target.syntax +: cmd.args).toArray
886
899
if (! state.status.isOk) Task .now(state)
@@ -889,7 +902,7 @@ final class BloopBspServices(
889
902
case platform @ Platform .Js (config, _, _) =>
890
903
val cmd = Commands .Run (List (project.name))
891
904
val target = ScalaJsToolchain .linkTargetFrom(project, config)
892
- linkMainWithJs(cmd, project, state, mainClass.`class` , target, platform)
905
+ linkMainWithJs(cmd, project, state, mainClass.className , target, platform)
893
906
.flatMap { state =>
894
907
// We use node to run the program (is this a special case?)
895
908
val args = (" node" +: target.syntax +: cmd.args).toArray
@@ -1040,10 +1053,10 @@ final class BloopBspServices(
1040
1053
}
1041
1054
1042
1055
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 )
1047
1060
)
1048
1061
val isJavaOnly = p.scalaInstance.isEmpty
1049
1062
val languageIds =
@@ -1256,8 +1269,8 @@ final class BloopBspServices(
1256
1269
bsp.ScalacOptionsItem (
1257
1270
target = target,
1258
1271
options = project.scalacOptions.toList,
1259
- classpath = classpath,
1260
- classDirectory = classesDir
1272
+ classpath = classpath.map(_.value) ,
1273
+ classDirectory = classesDir.value
1261
1274
)
1262
1275
}.toList
1263
1276
)
@@ -1290,8 +1303,8 @@ final class BloopBspServices(
1290
1303
bsp.JavacOptionsItem (
1291
1304
target = target,
1292
1305
options = project.javacOptions.toList,
1293
- classpath = classpath,
1294
- classDirectory = classesDir
1306
+ classpath = classpath.map(_.value) ,
1307
+ classDirectory = classesDir.value
1295
1308
)
1296
1309
}.toList
1297
1310
)
0 commit comments