Skip to content

Commit fa62f9a

Browse files
committed
Use common sense options in Bsp operations, change test that fails, but in reality does not test anything with the last call to compile.
1 parent 830ab30 commit fa62f9a

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ final class BspImpl(
8080
event
8181
}
8282
val params = new b.DidChangeBuildTarget(events.asJava)
83+
pprint.err.log(params)
8384
actualLocalClient.onBuildTargetDidChange(params)
8485
}
8586

@@ -369,6 +370,7 @@ final class BspImpl(
369370
new b.CompileResult(b.StatusCode.ERROR)
370371
)
371372
case Right(params) =>
373+
println(params)
372374
for (targetId <- currentBloopSession.bspServer.targetIds)
373375
actualLocalClient.resetBuildExceptionDiagnostics(targetId)
374376

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,10 @@ class BspServer(
192192
): CompletableFuture[b.CleanCacheResult] =
193193
super.buildTargetCleanCache(check(params))
194194

195-
override def buildTargetCompile(params: b.CompileParams): CompletableFuture[b.CompileResult] =
195+
override def buildTargetCompile(params: b.CompileParams): CompletableFuture[b.CompileResult] = {
196+
pprint.err.log(params)
196197
compile(() => super.buildTargetCompile(check(params)))
198+
}
197199

198200
override def buildTargetDependencySources(
199201
params: b.DependencySourcesParams

modules/build/src/test/scala/scala/build/input/compose/InputsComposerTest.scala

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,19 @@ class InputsComposerTest extends TestUtil.ScalaCliBuildSuite {
101101

102102
val buildOrder = inputs.modulesBuildOrder
103103

104-
def baseProjectName(projectName: ProjectName): String = {
104+
def baseProjectName(projectName: ProjectName): String =
105105
projectName.name.take(projectName.name.indexOf("_"))
106-
}
107106

108-
assert(buildOrder.map(_.projectName).map(baseProjectName) == Seq("utils", "core", "root1", "root2", "uberRoot"), clue = buildOrder.map(_.projectName).map(baseProjectName))
107+
assert(
108+
buildOrder.map(_.projectName).map(baseProjectName) == Seq(
109+
"utils",
110+
"core",
111+
"root1",
112+
"root2",
113+
"uberRoot"
114+
),
115+
clue = buildOrder.map(_.projectName).map(baseProjectName)
116+
)
109117
}
110118
}
111119
}

modules/cli/src/main/scala/scala/cli/commands/bsp/Bsp.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ object Bsp extends ScalaCommand[BspOptions] {
136136

137137
val inputsAndBuildOptions = preprocessInputs(args.all).orExit(logger)
138138

139-
// TODO reported override option values
140-
// FIXME Only some options need to be unified for the whole project, like scala version, JVM
141139
val combinedBuildOptions = inputsAndBuildOptions._2.reduceLeft(_ orElse _)
142140
val inputs = inputsAndBuildOptions._1
143141

@@ -154,11 +152,15 @@ object Bsp extends ScalaCommand[BspOptions] {
154152
val envs = getEnvsFromFile()
155153
val bspBuildOptions = buildOptions(sharedOptions, launcherOptions, envs)
156154

155+
// For correctly launching a bloop server we need all options, including ones from sources, e.g. for using a correct version of JVM
156+
// FIXME pick highest JVM version for launching bloop out of all specified
157+
val bloopRifleConfigOptions = bspBuildOptions.orElse(combinedBuildOptions)
158+
157159
refreshPowerMode(launcherOptions, sharedOptions, envs)
158160

159161
BspReloadableOptions(
160162
buildOptions = bspBuildOptions,
161-
bloopRifleConfig = sharedOptions.bloopRifleConfig(Some(finalBuildOptions))
163+
bloopRifleConfig = sharedOptions.bloopRifleConfig(Some(bloopRifleConfigOptions))
162164
.orExit(sharedOptions.logger),
163165
logger = sharedOptions.logging.logger,
164166
verbosity = sharedOptions.logging.verbosity

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
package scala.cli.integration
22

3-
import ch.epfl.scala.bsp4j.{BuildTargetEvent, JvmTestEnvironmentParams}
3+
import ch.epfl.scala.bsp4j.{BuildTargetEvent, JvmTestEnvironmentParams, SourcesParams}
44
import ch.epfl.scala.bsp4j as b
55
import com.eed3si9n.expecty.Expecty.expect
66
import com.google.gson.{Gson, JsonElement}
77

88
import java.net.URI
99
import java.nio.file.Paths
1010
import java.util.concurrent.{ExecutorService, ScheduledExecutorService}
11-
1211
import scala.annotation.tailrec
1312
import scala.async.Async.{async, await}
1413
import scala.cli.integration.compose.ComposeBspTestDefinitions
@@ -779,7 +778,7 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
779778
}
780779
}
781780

782-
test("test workspace update after adding file to main scope") {
781+
test("tes scope uses artifacts from main scope") {
783782
val inputs = TestInputs(
784783
os.rel / "Messages.scala" ->
785784
"""//> using dep "com.lihaoyi::os-lib:0.7.8"

0 commit comments

Comments
 (0)