@@ -9,27 +9,33 @@ import scala.build.compiler.BloopCompiler
99import scala .build .input .{ModuleInputs , OnDisk , SingleFile , Virtual }
1010
1111final class BloopSession (
12- val inputs : ModuleInputs ,
13- val inputsHash : String ,
12+ val inputs : Seq [ ModuleInputs ] ,
13+ // val inputsHash: String, TODO Fix inputs hash comparing
1414 val remoteServer : BloopCompiler ,
1515 val bspServer : BspServer ,
1616 val watcher : Build .Watcher
1717) {
1818 // TODO this resets diagnostics using paths that do not belong to the build targets
19- def resetDiagnostics (localClient : BspClient ): Unit =
20- for (targetId <- bspServer.targetIds)
21- inputs.flattened().foreach {
22- case f : SingleFile =>
23- localClient.resetDiagnostics(f.path, targetId)
24- case _ : Virtual =>
25- }
19+ def resetDiagnostics (localClient : BspClient ): Unit = for {
20+ moduleInputs <- inputs
21+ targetId <- bspServer.targetProjectIdOpt(moduleInputs.projectName)
22+ } do
23+ moduleInputs.flattened().foreach {
24+ case f : SingleFile =>
25+ localClient.resetDiagnostics(f.path, targetId)
26+ case _ : Virtual =>
27+ }
28+
2629 def dispose (): Unit = {
2730 watcher.dispose()
2831 remoteServer.shutdown()
2932 }
3033
31- def registerWatchInputs (): Unit =
32- inputs.elements.foreach {
34+ def registerWatchInputs (): Unit = for {
35+ module <- inputs
36+ element <- module.elements
37+ } do
38+ element match {
3339 case elem : OnDisk =>
3440 val eventFilter : PathWatchers .Event => Boolean = { event =>
3541 val newOrDeletedFile =
@@ -38,8 +44,11 @@ final class BloopSession(
3844 lazy val p = os.Path (event.getTypedPath.getPath.toAbsolutePath)
3945 lazy val relPath = p.relativeTo(elem.path)
4046 lazy val isHidden = relPath.segments.exists(_.startsWith(" ." ))
41- def isScalaFile = relPath.last.endsWith(" .sc" ) || relPath.last.endsWith(" .scala" )
42- def isJavaFile = relPath.last.endsWith(" .java" )
47+
48+ def isScalaFile = relPath.last.endsWith(" .sc" ) || relPath.last.endsWith(" .scala" )
49+
50+ def isJavaFile = relPath.last.endsWith(" .java" )
51+
4352 newOrDeletedFile && ! isHidden && (isScalaFile || isJavaFile)
4453 }
4554 val watcher0 = watcher.newWatcher()
@@ -57,11 +66,11 @@ final class BloopSession(
5766object BloopSession {
5867
5968 def apply (
60- inputs : ModuleInputs ,
69+ inputs : Seq [ ModuleInputs ] ,
6170 remoteServer : BloopCompiler ,
6271 bspServer : BspServer ,
6372 watcher : Build .Watcher
64- ): BloopSession = new BloopSession (inputs, inputs.sourceHash(), remoteServer, bspServer, watcher)
73+ ): BloopSession = new BloopSession (inputs, remoteServer, bspServer, watcher)
6574
6675 final class Reference {
6776 private val ref = new AtomicReference [BloopSession ](null )
0 commit comments