File tree Expand file tree Collapse file tree 12 files changed +50
-53
lines changed
tasty-inspector/src/scala/tasty/inspector
tastydoc/src/dotty/tastydoc
tasty-interpreter/interpreter Expand file tree Collapse file tree 12 files changed +50
-53
lines changed Original file line number Diff line number Diff line change 11package scala .tasty .inspector
22
3- import scala .tasty . Reflection
3+ import scala .quoted . _
44
55import dotty .tools .dotc .Compiler
66import dotty .tools .dotc .Driver
@@ -18,7 +18,7 @@ trait TastyInspector:
1818 self =>
1919
2020 /** Process a TASTy file using TASTy reflect */
21- protected def processCompilationUnit (reflect : Reflection )(root : reflect .Tree ): Unit
21+ protected def processCompilationUnit (using QuoteContext )(root : qctx.tasty .Tree ): Unit
2222
2323 /** Load and process TASTy files using TASTy reflect
2424 *
@@ -58,7 +58,7 @@ trait TastyInspector:
5858
5959 override def run (implicit ctx : Context ): Unit =
6060 val qctx = QuoteContextImpl ()
61- self.processCompilationUnit(qctx.tasty )(ctx.compilationUnit.tpdTree.asInstanceOf [qctx.tasty.Tree ])
61+ self.processCompilationUnit(using qctx)(ctx.compilationUnit.tpdTree.asInstanceOf [qctx.tasty.Tree ])
6262
6363 end TastyInspectorPhase
6464
Original file line number Diff line number Diff line change 11package dotty .tastydoc
22
3- import scala .tasty . Reflection
3+ import scala .quoted . _
44import scala .tasty .inspector .TastyInspector
55
66import dotty .tastydoc .representations ._
@@ -11,9 +11,7 @@ import dotty.tastydoc.representations._
1111 */
1212class TastydocInspector (mutablePackagesMap : scala.collection.mutable.HashMap [String , EmulatedPackageRepresentation ]) extends TastyInspector {
1313
14- protected def processCompilationUnit (reflect : Reflection )(root : reflect.Tree ): Unit = {
15- import reflect ._
16-
17- representations.convertToRepresentation(reflect)(root, None )(using mutablePackagesMap)
14+ protected def processCompilationUnit (using QuoteContext )(root : qctx.tasty.Tree ): Unit = {
15+ representations.convertToRepresentation(qctx.tasty)(root, None )(using mutablePackagesMap)
1816 }
1917}
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import scala.annotation.tailrec
55import dotty .tastydoc .comment .Comment
66import dotty .tastydoc .references ._
77
8+ // TODO pass QuoteContext around insead of Reflection
9+
810object representations extends TastyExtractor {
911
1012 trait Representation {
Original file line number Diff line number Diff line change 1- import scala .tasty . Reflection
1+ import scala .quoted . _
22import scala .tasty .inspector ._
33
44opaque type PhoneNumber = String
@@ -16,16 +16,15 @@ object Test {
1616
1717class TestInspector () extends TastyInspector :
1818
19- protected def processCompilationUnit (reflect : Reflection )(root : reflect.Tree ): Unit =
20- import reflect ._
21- inspectClass(reflect)(root)
19+ protected def processCompilationUnit (using QuoteContext )(root : qctx.tasty.Tree ): Unit =
20+ inspectClass(root)
2221
23- private def inspectClass (reflect : Reflection )(tree : reflect .Tree ): Unit =
24- import reflect .{ given _ , _ }
22+ private def inspectClass (using QuoteContext )(tree : qctx.tasty .Tree ): Unit =
23+ import qctx . tasty . _
2524 tree match {
26- case t : reflect. PackageClause =>
27- t.stats.map( m => inspectClass(reflect)( m) )
28- case t : reflect. ClassDef if ! t.name.endsWith(" $" ) =>
25+ case t : PackageClause =>
26+ t.stats.map( m => inspectClass(m) )
27+ case t : ClassDef if ! t.name.endsWith(" $" ) =>
2928 val interestingVals = t.body.collect {
3029 case v : ValDef => v
3130 }
Original file line number Diff line number Diff line change 1- import scala .tasty . Reflection
1+ import scala .quoted . _
22import scala .tasty .inspector ._
33
44case class I8215 (id : String )
@@ -35,7 +35,7 @@ class TestInspector_NonTasty() extends TastyInspector:
3535 var isScala2 : Boolean = false
3636 var className : String = " "
3737
38- protected def processCompilationUnit (reflect : Reflection )(root : reflect .Tree ): Unit =
39- isJava = reflect .Source .isJavaCompilationUnit
40- isScala2 = reflect .Source .isScala2CompilationUnit
41- className = reflect .Source .compilationUnitClassname
38+ protected def processCompilationUnit (using QuoteContext )(root : qctx.tasty .Tree ): Unit =
39+ isJava = qctx.tasty .Source .isJavaCompilationUnit
40+ isScala2 = qctx.tasty .Source .isScala2CompilationUnit
41+ className = qctx.tasty .Source .compilationUnitClassname
Original file line number Diff line number Diff line change 1- import scala .tasty ._
1+ import scala .quoted ._
22import scala .tasty .inspector ._
33
44@ main def Test = {
55 val inspector = new TastyInspector {
6- def processCompilationUnit (reflect : Reflection )(tree : reflect.Tree ): Unit = {
7- import reflect .{_ , given _ }
6+ protected def processCompilationUnit (using QuoteContext )(tree : qctx.tasty.Tree ): Unit = {
87 println(tree.show)
98 }
109 }
Original file line number Diff line number Diff line change 1- import scala .tasty ._
1+ import scala .quoted ._
22import scala .tasty .inspector ._
33
44@ main def Test = {
55 // in dotty-example-project
66 val inspector = new TastyInspector {
7- def processCompilationUnit (reflect : Reflection )(tree : reflect.Tree ): Unit = {
8- import reflect .{_ , given _ }
7+ protected def processCompilationUnit (using QuoteContext )(tree : qctx.tasty.Tree ): Unit = {
98 println(tree.show)
109 }
1110 }
Original file line number Diff line number Diff line change 1- import scala .tasty . Reflection
1+ import scala .quoted . _
22import scala .tasty .inspector ._
33
44// Ambiguous member names
@@ -32,16 +32,16 @@ class TestInspector_Children() extends TastyInspector:
3232
3333 var kids : List [String ] = Nil
3434
35- protected def processCompilationUnit (reflect : Reflection )(root : reflect .Tree ): Unit =
36- import reflect ._
37- inspectClass(reflect)( root)
35+ protected def processCompilationUnit (using QuoteContext )(root : qctx.tasty .Tree ): Unit =
36+ import qctx . tasty ._
37+ inspectClass(root)
3838
39- private def inspectClass (reflect : Reflection )(tree : reflect .Tree ): Unit =
40- import reflect .{ given _ , _ }
39+ private def inspectClass (using QuoteContext )(tree : qctx.tasty .Tree ): Unit =
40+ import qctx . tasty . _
4141 tree match {
42- case t : reflect. PackageClause =>
43- t.stats.map( m => inspectClass(reflect)( m) )
44- case t : reflect. ClassDef =>
42+ case t : PackageClause =>
43+ t.stats.map( m => inspectClass(m) )
44+ case t : ClassDef =>
4545 kids = t.symbol.children.map(_.fullName)
4646
4747 case x =>
Original file line number Diff line number Diff line change 1- import scala .tasty . Reflection
1+ import scala .quoted . _
22import scala .tasty .inspector ._
33
44object Test {
@@ -17,6 +17,6 @@ class TestInspector_NonTasty() extends TastyInspector:
1717 var isAlreadyLoaded : Boolean = false
1818 var className : String = " "
1919
20- protected def processCompilationUnit (reflect : Reflection )(root : reflect .Tree ): Unit =
21- isAlreadyLoaded = reflect .Source .isAlreadyLoadedCompilationUnit
22- className = reflect .Source .compilationUnitClassname
20+ protected def processCompilationUnit (using QuoteContext )(root : qctx.tasty .Tree ): Unit =
21+ isAlreadyLoaded = qctx.tasty .Source .isAlreadyLoadedCompilationUnit
22+ className = qctx.tasty .Source .compilationUnitClassname
Original file line number Diff line number Diff line change 1- import scala .tasty . Reflection
1+ import scala .quoted . _
22import scala .tasty .inspector ._
33
44object Test {
@@ -9,8 +9,8 @@ object Test {
99
1010class CommentInspector extends TastyInspector {
1111
12- def processCompilationUnit (reflect : Reflection )(root : reflect .Tree ): Unit = {
13- import reflect .{ _ , given _ }
12+ protected def processCompilationUnit (using QuoteContext )(root : qctx.tasty .Tree ): Unit = {
13+ import qctx . tasty . _
1414 object Traverser extends TreeTraverser {
1515
1616 override def traverseTree (tree : Tree )(implicit ctx : Context ): Unit = tree match {
@@ -25,7 +25,7 @@ class CommentInspector extends TastyInspector {
2525 }
2626
2727 }
28- Traverser .traverseTree(root)(reflect.rootContext)
28+ Traverser .traverseTree(root)
2929 }
3030
3131}
You can’t perform that action at this time.
0 commit comments