@@ -9,27 +9,33 @@ import scala.build.compiler.BloopCompiler
9
9
import scala .build .input .{ModuleInputs , OnDisk , SingleFile , Virtual }
10
10
11
11
final class BloopSession (
12
- val inputs : ModuleInputs ,
13
- val inputsHash : String ,
12
+ val inputs : Seq [ ModuleInputs ] ,
13
+ // val inputsHash: String, TODO Fix inputs hash comparing
14
14
val remoteServer : BloopCompiler ,
15
15
val bspServer : BspServer ,
16
16
val watcher : Build .Watcher
17
17
) {
18
18
// 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
+
26
29
def dispose (): Unit = {
27
30
watcher.dispose()
28
31
remoteServer.shutdown()
29
32
}
30
33
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 {
33
39
case elem : OnDisk =>
34
40
val eventFilter : PathWatchers .Event => Boolean = { event =>
35
41
val newOrDeletedFile =
@@ -38,8 +44,11 @@ final class BloopSession(
38
44
lazy val p = os.Path (event.getTypedPath.getPath.toAbsolutePath)
39
45
lazy val relPath = p.relativeTo(elem.path)
40
46
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
+
43
52
newOrDeletedFile && ! isHidden && (isScalaFile || isJavaFile)
44
53
}
45
54
val watcher0 = watcher.newWatcher()
@@ -57,11 +66,11 @@ final class BloopSession(
57
66
object BloopSession {
58
67
59
68
def apply (
60
- inputs : ModuleInputs ,
69
+ inputs : Seq [ ModuleInputs ] ,
61
70
remoteServer : BloopCompiler ,
62
71
bspServer : BspServer ,
63
72
watcher : Build .Watcher
64
- ): BloopSession = new BloopSession (inputs, inputs.sourceHash(), remoteServer, bspServer, watcher)
73
+ ): BloopSession = new BloopSession (inputs, remoteServer, bspServer, watcher)
65
74
66
75
final class Reference {
67
76
private val ref = new AtomicReference [BloopSession ](null )
0 commit comments