Skip to content

Commit 7d86966

Browse files
committed
Maintain compilationUnits mapping
We need that to be able to establish precise contexts.
1 parent 9f4dac2 commit 7d86966

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ class InteractiveDriver(settings: List[String]) extends Driver {
5050
override def default(key: URI) = Nil
5151
}
5252

53+
private val myCompilationUnits = new mutable.LinkedHashMap[URI, CompilationUnit]
54+
5355
def openedFiles: Map[URI, SourceFile] = myOpenedFiles
5456
def openedTrees: Map[URI, List[SourceTree]] = myOpenedTrees
57+
def compilationUnits: Map[URI, CompilationUnit] = myCompilationUnits
5558

5659
def allTrees(implicit ctx: Context): List[SourceTree] = allTreesContaining("")
5760

@@ -229,9 +232,11 @@ class InteractiveDriver(settings: List[String]) extends Driver {
229232

230233
run.compileSources(List(source))
231234
run.printSummary()
232-
val t = ctx.run.units.head.tpdTree
235+
val unit = ctx.run.units.head
236+
val t = unit.tpdTree
233237
cleanup(t)
234238
myOpenedTrees(uri) = topLevelClassTrees(t, source)
239+
myCompilationUnits(uri) = unit
235240

236241
reporter.removeBufferedMessages
237242
}
@@ -246,6 +251,7 @@ class InteractiveDriver(settings: List[String]) extends Driver {
246251
def close(uri: URI): Unit = {
247252
myOpenedFiles.remove(uri)
248253
myOpenedTrees.remove(uri)
254+
myCompilationUnits.remove(uri)
249255
}
250256
}
251257

0 commit comments

Comments
 (0)