@@ -34,19 +34,18 @@ import scala.annotation.internal.sharable
3434
3535import DenotTransformers .DenotTransformer
3636import dotty .tools .dotc .profile .Profiler
37+ import dotty .tools .dotc .sbt .interfaces .IncrementalCallback
3738import util .Property .Key
3839import util .Store
39- import xsbti .AnalysisCallback
4040import plugins ._
4141import java .util .concurrent .atomic .AtomicInteger
42- import java .util .Map as JMap
4342import java .nio .file .InvalidPathException
4443
4544
4645object Contexts {
4746
4847 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 ]()
5049 private val (printerFnLoc, store3) = store2.newLocation[Context => Printer ](new RefinedPrinter (_))
5150 private val (settingsStateLoc, store4) = store3.newLocation[SettingsState ]()
5251 private val (compilationUnitLoc, store5) = store4.newLocation[CompilationUnit ]()
@@ -55,9 +54,8 @@ object Contexts {
5554 private val (notNullInfosLoc, store8) = store7.newLocation[List [NotNullInfo ]]()
5655 private val (importInfoLoc, store9) = store8.newLocation[ImportInfo | Null ]()
5756 private val (typeAssignerLoc, store10) = store9.newLocation[TypeAssigner ](TypeAssigner )
58- private val (zincVirtualFilesLoc, store11) = store10.newLocation[JMap [String , xsbti.VirtualFile ] | Null ]()
5957
60- private val initialStore = store11
58+ private val initialStore = store10
6159
6260 /** The current context */
6361 inline def ctx (using ctx : Context ): Context = ctx
@@ -168,10 +166,17 @@ object Contexts {
168166 def compilerCallback : CompilerCallback = store(compilerCallbackLoc)
169167
170168 /** 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 )
172170
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
175180
176181 /** The current plain printer */
177182 def printerFn : Context => Printer = store(printerFnLoc)
@@ -670,9 +675,7 @@ object Contexts {
670675 }
671676
672677 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)
676679 def setPrinterFn (printer : Context => Printer ): this .type = updateStore(printerFnLoc, printer)
677680 def setSettings (settingsState : SettingsState ): this .type = updateStore(settingsStateLoc, settingsState)
678681 def setRun (run : Run | Null ): this .type = updateStore(runLoc, run)
0 commit comments