File tree Expand file tree Collapse file tree 4 files changed +42
-7
lines changed
mtags/src/main/scala-3/scala/meta/internal/pc Expand file tree Collapse file tree 4 files changed +42
-7
lines changed Original file line number Diff line number Diff line change
1
+ package scala .meta .internal .pc
2
+
3
+ import java .net .URI
4
+ import java .{util as ju }
5
+
6
+ import scala .collection .concurrent .TrieMap
7
+
8
+ import scala .meta .internal .mtags .MD5
9
+
10
+ import dotty .tools .dotc .core .Contexts .Context
11
+ import dotty .tools .dotc .interactive .InteractiveDriver
12
+ import dotty .tools .dotc .interactive .SourceTree
13
+ import dotty .tools .dotc .reporting .Diagnostic
14
+ import dotty .tools .dotc .util .SourceFile
15
+
16
+ class MetalsDriver (
17
+ override val settings : List [String ]
18
+ ) extends InteractiveDriver (settings):
19
+
20
+ private def alreadyCompiled (uri : URI , content : Array [Char ]): Boolean =
21
+ compilationUnits.get(uri) match
22
+ case Some (unit) if ju.Arrays .equals(unit.source.content(), content) =>
23
+ true
24
+ case _ => false
25
+
26
+ override def run (uri : URI , source : SourceFile ): List [Diagnostic ] =
27
+ if alreadyCompiled(uri, source.content) then Nil
28
+ else super .run(uri, source)
29
+
30
+ override def run (uri : URI , sourceCode : String ): List [Diagnostic ] =
31
+ val contentHash = MD5 .compute(sourceCode)
32
+ if alreadyCompiled(uri, sourceCode.toCharArray()) then Nil
33
+ else super .run(uri, sourceCode)
34
+
35
+ end MetalsDriver
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ class Scala3CompilerAccess(
24
24
sh : Option [ScheduledExecutorService ],
25
25
newCompiler : () => Scala3CompilerWrapper ,
26
26
)(using ec : ExecutionContextExecutor )
27
- extends CompilerAccess [StoreReporter , InteractiveDriver ](
27
+ extends CompilerAccess [StoreReporter , MetalsDriver ](
28
28
config,
29
29
sh,
30
30
newCompiler,
Original file line number Diff line number Diff line change @@ -7,10 +7,10 @@ import dotty.tools.dotc.core.Contexts.Context
7
7
import dotty .tools .dotc .interactive .InteractiveDriver
8
8
import dotty .tools .dotc .reporting .StoreReporter
9
9
10
- class Scala3CompilerWrapper (driver : InteractiveDriver )
11
- extends CompilerWrapper [StoreReporter , InteractiveDriver ]:
10
+ class Scala3CompilerWrapper (driver : MetalsDriver )
11
+ extends CompilerWrapper [StoreReporter , MetalsDriver ]:
12
12
13
- override def compiler (): InteractiveDriver = driver
13
+ override def compiler (): MetalsDriver = driver
14
14
15
15
override def resetReporter (): Unit =
16
16
val ctx = driver.currentCtx
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ case class ScalaPresentationCompiler(
54
54
private val forbiddenOptions = Set (" -print-lines" , " -print-tasty" )
55
55
private val forbiddenDoubleOptions = Set (" -release" )
56
56
57
- val compilerAccess : CompilerAccess [StoreReporter , InteractiveDriver ] =
57
+ val compilerAccess : CompilerAccess [StoreReporter , MetalsDriver ] =
58
58
Scala3CompilerAccess (
59
59
config,
60
60
sh,
@@ -70,7 +70,7 @@ case class ScalaPresentationCompiler(
70
70
case head :: tail => head :: removeDoubleOptions(tail)
71
71
case Nil => options
72
72
73
- def newDriver : InteractiveDriver =
73
+ def newDriver : MetalsDriver =
74
74
val implicitSuggestionTimeout = List (" -Ximport-suggestion-timeout" , " 0" )
75
75
val defaultFlags = List (" -color:never" )
76
76
val filteredOptions = removeDoubleOptions(
@@ -81,7 +81,7 @@ case class ScalaPresentationCompiler(
81
81
.mkString(
82
82
File .pathSeparator
83
83
) :: Nil
84
- new InteractiveDriver (settings)
84
+ new MetalsDriver (settings)
85
85
86
86
override def getTasty (
87
87
targetUri : URI ,
You can’t perform that action at this time.
0 commit comments