@@ -20,6 +20,9 @@ trait TastyInspector:
20
20
/** Process a TASTy file using TASTy reflect */
21
21
protected def processCompilationUnit (using QuoteContext )(root : qctx.reflect.Tree ): Unit
22
22
23
+ /** Called after all compilation units are processed */
24
+ protected def finishProcessingCompilationUnits (using QuoteContext ): Unit = ()
25
+
23
26
/** Load and process TASTy files using TASTy reflect
24
27
*
25
28
* @param tastyFiles List of paths of `.tasty` files
@@ -70,7 +73,8 @@ trait TastyInspector:
70
73
override protected def transformPhases : List [List [Phase ]] = Nil
71
74
72
75
override protected def backendPhases : List [List [Phase ]] =
73
- List (new TastyInspectorPhase ) :: // Print all loaded classes
76
+ List (new TastyInspectorPhase ) :: // Perform a callback for each compilation unit
77
+ List (new TastyInspectorFinishPhase ) :: // Perform a final callback
74
78
Nil
75
79
76
80
override def newRun (implicit ctx : Context ): Run =
@@ -89,6 +93,19 @@ trait TastyInspector:
89
93
90
94
end TastyInspectorPhase
91
95
96
+ class TastyInspectorFinishPhase extends Phase :
97
+
98
+ override def phaseName : String = " tastyInspectorFinish"
99
+
100
+ override def run (implicit ctx : Context ): Unit =
101
+ if ! alreadyRan then
102
+ val qctx = QuoteContextImpl ()
103
+ self.finishProcessingCompilationUnits(using qctx)
104
+ alreadyRan = true
105
+
106
+ var alreadyRan = false
107
+ end TastyInspectorFinishPhase
108
+
92
109
val currentClasspath = ClasspathFromClassloader (getClass.getClassLoader)
93
110
val fullClasspath = (classpath :+ currentClasspath).mkString(pathSeparator)
94
111
val args = " -from-tasty" :: " -Yretain-trees" :: " -classpath" :: fullClasspath :: classes
0 commit comments