Skip to content

Commit 1122b62

Browse files
committed
Remember late-loaded units in Run
Store them in `lateUnits` (and `lateFiles` for the associated files). An IDE can inquire about units and persist them to the next runs.
1 parent 3f40fc4 commit 1122b62

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

compiler/src/dotty/tools/dotc/Run.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import java.io.{BufferedWriter, OutputStreamWriter}
2020
import printing.XprintMode
2121
import parsing.Parsers.Parser
2222
import typer.ImplicitRunInfo
23+
import collection.mutable
2324

2425
import scala.annotation.tailrec
2526
import dotty.tools.io.VirtualFile
@@ -68,6 +69,12 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
6869
private[this] var myUnitsCached: List[CompilationUnit] = _
6970
private[this] var myFiles: Set[AbstractFile] = _
7071

72+
/** Units that are added because of source completers but that are not
73+
* compiled in current run.
74+
*/
75+
val lateUnits = mutable.ListBuffer[CompilationUnit]()
76+
var lateFiles = mutable.Set[AbstractFile]()
77+
7178
/** The compilation units currently being compiled, this may return different
7279
* results over time.
7380
*/
@@ -175,8 +182,10 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
175182
* The newly added symbols replace any previously entered symbols.
176183
*/
177184
def enterRoots(file: AbstractFile)(implicit ctx: Context): Unit =
178-
if (!files.contains(file)) {
185+
if (!files.contains(file) && !lateFiles.contains(file)) {
179186
val unit = new CompilationUnit(getSource(file.path))
187+
lateUnits += unit
188+
lateFiles += file
180189
enterRoots(unit)(runContext.fresh.setCompilationUnit(unit))
181190
}
182191

0 commit comments

Comments
 (0)