Skip to content

Commit 01960be

Browse files
authored
Update bsp4j to 2.1.0-M1 (#1277)
1 parent 55123ab commit 01960be

File tree

13 files changed

+41
-47
lines changed

13 files changed

+41
-47
lines changed

modules/bloop-rifle/src/main/scala/scala/build/bloop/BuildServer.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ package scala.build.bloop
33
import ch.epfl.scala.bsp4j
44

55
trait BuildServer extends bsp4j.BuildServer with bsp4j.ScalaBuildServer with bsp4j.JavaBuildServer
6-
with ScalaDebugServer

modules/bloop-rifle/src/main/scala/scala/build/bloop/ScalaDebugServer.scala

Lines changed: 0 additions & 11 deletions
This file was deleted.

modules/bloop-rifle/src/main/scala/scala/build/bloop/ScalaDebugServerForwardStubs.scala

Lines changed: 0 additions & 13 deletions
This file was deleted.

modules/build/src/main/scala/scala/build/bsp/BspClient.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class BspClient(
199199
diag.relatedInformation.foreach { relatedInformation =>
200200
val location = new Location(path.toNIO.toUri.toASCIIString, range)
201201
val related = new b.DiagnosticRelatedInformation(location, relatedInformation.message)
202-
bDiag.setRelatedInformation(related)
202+
bDiag.setRelatedInformation(List(related).asJava)
203203
}
204204
bDiag.setSeverity(diag.severity.toBsp4j)
205205
bDiag.setSource("scala-cli")

modules/build/src/main/scala/scala/build/bsp/BspImpl.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import java.io.{InputStream, OutputStream}
1010
import java.util.concurrent.{CompletableFuture, Executor}
1111
import scala.build.*
1212
import scala.build.EitherCps.{either, value}
13-
import scala.build.bloop.{BloopServer, ScalaDebugServer}
13+
import scala.build.bloop.BloopServer
1414
import scala.build.compiler.BloopCompiler
1515
import scala.build.errors.{BuildException, Diagnostic, ParsingInputsException}
1616
import scala.build.internal.{Constants, CustomCodeWrapper}
@@ -423,7 +423,7 @@ final class BspImpl(
423423
bloopSession.update(null, currentBloopSession, "BSP server already initialized")
424424

425425
val actualLocalServer: b.BuildServer with b.ScalaBuildServer with b.JavaBuildServer
426-
with ScalaDebugServer with ScalaScriptBuildServer with HasGeneratedSources =
426+
with ScalaScriptBuildServer with HasGeneratedSources =
427427
new BuildServerProxy(
428428
() => bloopSession.get().bspServer,
429429
() => onReload()

modules/build/src/main/scala/scala/build/bsp/BspServer.scala

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,19 @@ import java.util.concurrent.{CompletableFuture, TimeUnit}
99
import java.util as ju
1010

1111
import scala.build.Logger
12-
import scala.build.bloop.{ScalaDebugServer, ScalaDebugServerForwardStubs}
1312
import scala.build.internal.Constants
1413
import scala.build.options.Scope
1514
import scala.concurrent.{Future, Promise}
1615
import scala.jdk.CollectionConverters.*
1716
import scala.util.Random
1817

1918
class BspServer(
20-
bloopServer: b.BuildServer & b.ScalaBuildServer & b.JavaBuildServer & ScalaDebugServer,
19+
bloopServer: b.BuildServer & b.ScalaBuildServer & b.JavaBuildServer,
2120
compile: (() => CompletableFuture[b.CompileResult]) => CompletableFuture[b.CompileResult],
2221
logger: Logger,
2322
presetIntelliJ: Boolean = false
2423
) extends b.BuildServer with b.ScalaBuildServer with b.JavaBuildServer with BuildServerForwardStubs
2524
with ScalaScriptBuildServer
26-
with ScalaDebugServerForwardStubs
2725
with ScalaBuildServerForwardStubs with JavaBuildServerForwardStubs
2826
with HasGeneratedSourcesImpl {
2927

@@ -108,7 +106,12 @@ class BspServer(
108106
logger.debug(s"invalid target in Test request: $target")
109107
params
110108
}
111-
109+
private def check(params: b.DebugSessionParams): params.type = {
110+
val invalidTargets = params.getTargets.asScala.filter(!validTarget(_))
111+
for (target <- invalidTargets)
112+
logger.debug(s"invalid target in Test request: $target")
113+
params
114+
}
112115
private def mapGeneratedSources(res: b.SourcesResult): Unit = {
113116
val gen = generatedSources.values.toVector
114117
for {
@@ -123,8 +126,7 @@ class BspServer(
123126
}
124127
}
125128

126-
protected def forwardTo
127-
: b.BuildServer & b.ScalaBuildServer & b.JavaBuildServer & ScalaDebugServer = bloopServer
129+
protected def forwardTo: b.BuildServer & b.ScalaBuildServer & b.JavaBuildServer = bloopServer
128130

129131
private val supportedLanguages: ju.List[String] = List(
130132
"scala",
@@ -215,6 +217,10 @@ class BspServer(
215217
override def buildTargetTest(params: b.TestParams): CompletableFuture[b.TestResult] =
216218
super.buildTargetTest(check(params))
217219

220+
override def debugSessionStart(params: b.DebugSessionParams)
221+
: CompletableFuture[b.DebugSessionAddress] =
222+
super.debugSessionStart(check(params))
223+
218224
override def workspaceBuildTargets(): CompletableFuture[b.WorkspaceBuildTargetsResult] =
219225
super.workspaceBuildTargets().thenApply { res =>
220226
maybeUpdateProjectTargetUri(res)

modules/build/src/main/scala/scala/build/bsp/BuildServerForwardStubs.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ trait BuildServerForwardStubs extends b.BuildServer {
7070
forwardTo.buildTargetTest(params)
7171
.handle(fatalExceptionHandler("buildTargetTest", params))
7272

73+
override def debugSessionStart(params: b.DebugSessionParams)
74+
: CompletableFuture[b.DebugSessionAddress] =
75+
forwardTo.debugSessionStart(params)
76+
.handle(fatalExceptionHandler("debugSessionStart", params))
77+
7378
override def workspaceBuildTargets(): CompletableFuture[b.WorkspaceBuildTargetsResult] =
7479
forwardTo.workspaceBuildTargets()
7580
.handle(fatalExceptionHandler("workspaceBuildTargets"))

modules/build/src/main/scala/scala/build/bsp/BuildServerProxy.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ import ch.epfl.scala.{bsp4j => b}
44

55
import java.util.concurrent.CompletableFuture
66

7-
import scala.build.bloop.ScalaDebugServer
87
import scala.build.options.Scope
98
import scala.build.{GeneratedSource, Inputs}
109

1110
class BuildServerProxy(
1211
bspServer: () => BspServer,
1312
onReload: () => CompletableFuture[Object]
1413
) extends b.BuildServer with b.ScalaBuildServer with b.JavaBuildServer
15-
with ScalaDebugServer with ScalaScriptBuildServer with HasGeneratedSources {
14+
with ScalaScriptBuildServer with HasGeneratedSources {
1615
override def buildInitialize(params: b.InitializeBuildParams)
1716
: CompletableFuture[b.InitializeBuildResult] = bspServer().buildInitialize(params)
1817

@@ -67,9 +66,9 @@ class BuildServerProxy(
6766

6867
override def buildTargetJavacOptions(params: b.JavacOptionsParams)
6968
: CompletableFuture[b.JavacOptionsResult] = bspServer().buildTargetJavacOptions(params)
70-
71-
override def buildTargetDebugSession(params: b.DebugSessionParams)
72-
: CompletableFuture[b.DebugSessionAddress] = bspServer().buildTargetDebugSession(params)
69+
override def debugSessionStart(params: b.DebugSessionParams)
70+
: CompletableFuture[b.DebugSessionAddress] =
71+
bspServer().debugSessionStart(params)
7372

7473
override def buildTargetWrappedSources(params: WrappedSourcesParams)
7574
: CompletableFuture[WrappedSourcesResult] = bspServer().buildTargetWrappedSources(params)

modules/build/src/main/scala/scala/build/bsp/LoggingBuildServer.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ trait LoggingBuildServer extends b.BuildServer {
4141
underlying.buildTargetSources(pprint.err.log(params)).logF
4242
override def buildTargetTest(params: b.TestParams): CompletableFuture[b.TestResult] =
4343
underlying.buildTargetTest(pprint.err.log(params)).logF
44+
override def debugSessionStart(params: b.DebugSessionParams)
45+
: CompletableFuture[b.DebugSessionAddress] =
46+
underlying.debugSessionStart(pprint.err.log(params)).logF
4447
override def workspaceBuildTargets(): CompletableFuture[b.WorkspaceBuildTargetsResult] =
4548
underlying.workspaceBuildTargets().logF
4649
override def workspaceReload(): CompletableFuture[Object] =

modules/build/src/main/scala/scala/build/bsp/package.scala

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package scala.build
22

3-
import ch.epfl.scala.{bsp4j => b}
3+
import ch.epfl.scala.bsp4j as b
4+
import ch.epfl.scala.bsp4j.SourcesItem
45

56
import java.util.concurrent.CompletableFuture
6-
7-
import scala.jdk.CollectionConverters._
7+
import scala.jdk.CollectionConverters.*
88

99
package object bsp {
1010

@@ -44,7 +44,10 @@ package object bsp {
4444

4545
implicit class SourcesResultExt(private val res: b.SourcesResult) extends AnyVal {
4646
def duplicate(): b.SourcesResult =
47-
new b.SourcesResult(res.getItems().asScala.toList.map(_.duplicate()).asJava)
47+
new b.SourcesResult(
48+
res.getItems().asScala.toList
49+
.map((item: SourcesItem) => item.duplicate()).asJava
50+
)
4851
}
4952

5053
implicit class BuildTargetCapabilitiesExt(
@@ -102,7 +105,9 @@ package object bsp {
102105
def duplicate(): b.Diagnostic = {
103106
val diag0 = new b.Diagnostic(diag.getRange.duplicate(), diag.getMessage)
104107
diag0.setCode(diag.getCode)
105-
diag0.setRelatedInformation(Option(diag.getRelatedInformation).map(_.duplicate()).orNull)
108+
diag0.setRelatedInformation(
109+
Option(diag.getRelatedInformation).map(_.asScala.map(_.duplicate()).asJava).orNull
110+
)
106111
diag0.setSeverity(diag.getSeverity)
107112
diag0.setSource(diag.getSource)
108113
diag0

modules/cli/src/main/scala/scala/cli/internal/CliLogger.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import scala.build.internal.CustomProgressBarRefreshDisplay
1515
import scala.build.{ConsoleBloopBuildClient, Logger, Position}
1616
import scala.collection.mutable
1717
import scala.scalanative.{build => sn}
18+
import scala.jdk.CollectionConverters._
1819

1920
class CliLogger(
2021
val verbosity: Int,
@@ -88,7 +89,7 @@ class CliLogger(
8889
} {
8990
val location = new Location(filePath.toNIO.toUri.toASCIIString, range)
9091
val related = new b.DiagnosticRelatedInformation(location, info.message)
91-
diag.setRelatedInformation(related)
92+
diag.setRelatedInformation(List(related).asJava)
9293
}
9394

9495
for (file <- f.path) {

modules/integration/src/test/scala/scala/cli/integration/BspTestDefinitions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
11801180
strictlyCheckMessage = false
11811181
)
11821182

1183-
val relatedInformation = updateActionableDiagnostic.getRelatedInformation()
1183+
val relatedInformation = updateActionableDiagnostic.getRelatedInformation().asScala.head
11841184
expect(relatedInformation.getMessage.contains("com.lihaoyi::os-lib:"))
11851185
expect(
11861186
relatedInformation.getLocation().getUri() == (root / fileName).toNIO.toUri.toASCIIString

project/deps.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ object Deps {
6868
def asm = ivy"org.ow2.asm:asm:9.3"
6969
// Force using of 2.13 - is there a better way?
7070
def bloopConfig = ivy"io.github.alexarchambault.bleep:bloop-config_2.13:1.5.3-sc-1"
71-
def bsp4j = ivy"ch.epfl.scala:bsp4j:2.0.0"
71+
def bsp4j = ivy"ch.epfl.scala:bsp4j:2.1.0-M1"
7272
def caseApp = ivy"com.github.alexarchambault:case-app_2.13:2.1.0-M15"
7373
def collectionCompat = ivy"org.scala-lang.modules::scala-collection-compat:2.8.1"
7474
// Force using of 2.13 - is there a better way?

0 commit comments

Comments
 (0)