From a825c115c295deea0286afce058e5cc0e714badc Mon Sep 17 00:00:00 2001 From: Adrien Piquerez Date: Wed, 30 Jun 2021 10:31:43 +0200 Subject: [PATCH] [BSP] Ignore sbt target in resources request --- .../scala/sbt/internal/server/BuildServerProtocol.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala b/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala index c400fd9c3..7036a379b 100644 --- a/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala +++ b/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala @@ -155,9 +155,10 @@ object BuildServerProtocol { bspBuildTargetSources / aggregate := false, bspBuildTargetResources := Def.inputTaskDyn { val s = state.value - val workspace = bspWorkspace.value val targets = spaceDelimited().parsed.map(uri => BuildTargetIdentifier(URI.create(uri))) - val filter = ScopeFilter.in(targets.map(workspace)) + val workspace = bspFullWorkspace.value.filter(targets) + workspace.warnIfBuildsNonEmpty(Method.Resources, s.log) + val filter = ScopeFilter.in(workspace.scopes.values.toList) // run the worker task concurrently Def.task { val items = bspBuildTargetResourcesItem.all(filter).value @@ -309,6 +310,7 @@ object BuildServerProtocol { final val Reload = "workspace/reload" final val Shutdown = "build/shutdown" final val Sources = "buildTarget/sources" + final val Resources = "buildTarget/resources" final val DependencySources = "buildTarget/dependencySources" final val Compile = "buildTarget/compile" final val Test = "buildTarget/test" @@ -418,7 +420,7 @@ object BuildServerProtocol { val command = Keys.bspScalaMainClasses.key val _ = callback.appendExec(s"$command $targets", Some(r.id)) - case r if r.method == "buildTarget/resources" => + case r if r.method == Method.Resources => val param = Converter.fromJson[ResourcesParams](json(r)).get val targets = param.targets.map(_.uri).mkString(" ") val command = Keys.bspBuildTargetResources.key