@@ -34,19 +34,18 @@ import scala.annotation.internal.sharable
34
34
35
35
import DenotTransformers .DenotTransformer
36
36
import dotty .tools .dotc .profile .Profiler
37
+ import dotty .tools .dotc .sbt .interfaces .IncrementalCallback
37
38
import util .Property .Key
38
39
import util .Store
39
- import xsbti .AnalysisCallback
40
40
import plugins ._
41
41
import java .util .concurrent .atomic .AtomicInteger
42
- import java .util .Map as JMap
43
42
import java .nio .file .InvalidPathException
44
43
45
44
46
45
object Contexts {
47
46
48
47
private val (compilerCallbackLoc, store1) = Store .empty.newLocation[CompilerCallback ]()
49
- private val (sbtCallbackLoc , store2) = store1.newLocation[AnalysisCallback ]()
48
+ private val (incCallbackLoc , store2) = store1.newLocation[IncrementalCallback | Null ]()
50
49
private val (printerFnLoc, store3) = store2.newLocation[Context => Printer ](new RefinedPrinter (_))
51
50
private val (settingsStateLoc, store4) = store3.newLocation[SettingsState ]()
52
51
private val (compilationUnitLoc, store5) = store4.newLocation[CompilationUnit ]()
@@ -55,9 +54,8 @@ object Contexts {
55
54
private val (notNullInfosLoc, store8) = store7.newLocation[List [NotNullInfo ]]()
56
55
private val (importInfoLoc, store9) = store8.newLocation[ImportInfo | Null ]()
57
56
private val (typeAssignerLoc, store10) = store9.newLocation[TypeAssigner ](TypeAssigner )
58
- private val (zincVirtualFilesLoc, store11) = store10.newLocation[JMap [String , xsbti.VirtualFile ] | Null ]()
59
57
60
- private val initialStore = store11
58
+ private val initialStore = store10
61
59
62
60
/** The current context */
63
61
inline def ctx (using ctx : Context ): Context = ctx
@@ -168,10 +166,17 @@ object Contexts {
168
166
def compilerCallback : CompilerCallback = store(compilerCallbackLoc)
169
167
170
168
/** The Zinc callback implementation if we are run from Zinc, null otherwise */
171
- def sbtCallback : AnalysisCallback = store(sbtCallbackLoc )
169
+ def incCallback : IncrementalCallback | Null = store(incCallbackLoc )
172
170
173
- /** A map from absolute path to VirtualFile if we are run from Zinc, null otherwise */
174
- def zincVirtualFiles : JMap [String , xsbti.VirtualFile ] | Null = store(zincVirtualFilesLoc)
171
+ /** Run `op` if there exists an incremental callback */
172
+ inline def withIncCallback (inline op : IncrementalCallback => Unit ): Unit =
173
+ val local = incCallback
174
+ if local != null then op(local)
175
+
176
+ def incrementalEnabled : Boolean =
177
+ val local = incCallback
178
+ if local != null then local.enabled
179
+ else false
175
180
176
181
/** The current plain printer */
177
182
def printerFn : Context => Printer = store(printerFnLoc)
@@ -670,9 +675,7 @@ object Contexts {
670
675
}
671
676
672
677
def setCompilerCallback (callback : CompilerCallback ): this .type = updateStore(compilerCallbackLoc, callback)
673
- def setSbtCallback (callback : AnalysisCallback ): this .type = updateStore(sbtCallbackLoc, callback)
674
- def setZincVirtualFiles (map : JMap [String , xsbti.VirtualFile ]): this .type =
675
- updateStore(zincVirtualFilesLoc, map)
678
+ def setIncCallback (callback : IncrementalCallback ): this .type = updateStore(incCallbackLoc, callback)
676
679
def setPrinterFn (printer : Context => Printer ): this .type = updateStore(printerFnLoc, printer)
677
680
def setSettings (settingsState : SettingsState ): this .type = updateStore(settingsStateLoc, settingsState)
678
681
def setRun (run : Run | Null ): this .type = updateStore(runLoc, run)
0 commit comments