@@ -21,7 +21,9 @@ import transform.SymUtils._
21
21
22
22
import scala .collection .mutable
23
23
import scala .annotation .{ threadUnsafe => tu , tailrec }
24
+ import scala .jdk .CollectionConverters ._
24
25
import scala .PartialFunction .condOpt
26
+ import typer .ImportInfo .withRootImports
25
27
26
28
import dotty .tools .dotc .{semanticdb => s }
27
29
import dotty .tools .io .{AbstractFile , JarArchive }
@@ -59,18 +61,28 @@ class ExtractSemanticDB private (phaseMode: ExtractSemanticDB.PhaseMode, suffix:
59
61
// Check not needed since it does not transform trees
60
62
override def isCheckable : Boolean = false
61
63
62
- override def run (using Context ): Unit =
63
- val unit = ctx.compilationUnit
64
- if (phaseMode == ExtractSemanticDB .PhaseMode .PostTyper )
65
- val extractor = ExtractSemanticDB .Extractor ()
66
- extractor.extract(unit.tpdTree)
67
- ExtractSemanticDB .write(unit.source, extractor.occurrences.toList, extractor.symbolInfos.toList, extractor.synthetics.toList)
68
- else
69
- val warnings = ctx.reporter.allWarnings.collect {
70
- case w if w.pos.source == ctx.source => w.toSemanticDiagnostic
71
- }
72
- if (warnings.nonEmpty)
73
- ExtractSemanticDB .appendDiagnostics(unit.source, warnings)
64
+ override def runOn (units : List [CompilationUnit ])(using ctx : Context ): List [CompilationUnit ] = {
65
+ val appendWarnings = phaseMode == ExtractSemanticDB .PhaseMode .PostInlining
66
+ val warnings =
67
+ if (appendWarnings)
68
+ ctx.reporter.allWarnings.groupBy(w => w.pos.source)
69
+ else Map .empty
70
+
71
+ units.asJava.parallelStream().map { unit =>
72
+ val unitCtx = ctx.fresh.setCompilationUnit(unit).withRootImports
73
+ if (appendWarnings)
74
+ warnings.get(unit.source).foreach { ws =>
75
+ ExtractSemanticDB .appendDiagnostics(unit.source, ws.map(_.toSemanticDiagnostic))
76
+ }
77
+ else
78
+ val extractor = ExtractSemanticDB .Extractor ()
79
+ extractor.extract(unit.tpdTree)
80
+ ExtractSemanticDB .write(unit.source, extractor.occurrences.toList, extractor.symbolInfos.toList, extractor.synthetics.toList)
81
+ unit
82
+ }.toList().asScala.toList
83
+ }
84
+
85
+ def run (using Context ): Unit = unsupported(" run" )
74
86
end ExtractSemanticDB
75
87
76
88
object ExtractSemanticDB :
0 commit comments