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 1
1
package scala .tasty .inspector
2
2
3
- import scala .tasty . Reflection
3
+ import scala .quoted . _
4
4
5
5
import dotty .tools .dotc .Compiler
6
6
import dotty .tools .dotc .Driver
@@ -18,7 +18,7 @@ trait TastyInspector:
18
18
self =>
19
19
20
20
/** 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
22
22
23
23
/** Load and process TASTy files using TASTy reflect
24
24
*
@@ -58,7 +58,7 @@ trait TastyInspector:
58
58
59
59
override def run (implicit ctx : Context ): Unit =
60
60
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 ])
62
62
63
63
end TastyInspectorPhase
64
64
Original file line number Diff line number Diff line change 1
1
package dotty .tastydoc
2
2
3
- import scala .tasty . Reflection
3
+ import scala .quoted . _
4
4
import scala .tasty .inspector .TastyInspector
5
5
6
6
import dotty .tastydoc .representations ._
@@ -11,9 +11,7 @@ import dotty.tastydoc.representations._
11
11
*/
12
12
class TastydocInspector (mutablePackagesMap : scala.collection.mutable.HashMap [String , EmulatedPackageRepresentation ]) extends TastyInspector {
13
13
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)
18
16
}
19
17
}
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import scala.annotation.tailrec
5
5
import dotty .tastydoc .comment .Comment
6
6
import dotty .tastydoc .references ._
7
7
8
+ // TODO pass QuoteContext around insead of Reflection
9
+
8
10
object representations extends TastyExtractor {
9
11
10
12
trait Representation {
Original file line number Diff line number Diff line change 1
- import scala .tasty . Reflection
1
+ import scala .quoted . _
2
2
import scala .tasty .inspector ._
3
3
4
4
opaque type PhoneNumber = String
@@ -16,16 +16,15 @@ object Test {
16
16
17
17
class TestInspector () extends TastyInspector :
18
18
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)
22
21
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 . _
25
24
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(" $" ) =>
29
28
val interestingVals = t.body.collect {
30
29
case v : ValDef => v
31
30
}
Original file line number Diff line number Diff line change 1
- import scala .tasty . Reflection
1
+ import scala .quoted . _
2
2
import scala .tasty .inspector ._
3
3
4
4
case class I8215 (id : String )
@@ -35,7 +35,7 @@ class TestInspector_NonTasty() extends TastyInspector:
35
35
var isScala2 : Boolean = false
36
36
var className : String = " "
37
37
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 ._
2
2
import scala .tasty .inspector ._
3
3
4
4
@ main def Test = {
5
5
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 = {
8
7
println(tree.show)
9
8
}
10
9
}
Original file line number Diff line number Diff line change 1
- import scala .tasty ._
1
+ import scala .quoted ._
2
2
import scala .tasty .inspector ._
3
3
4
4
@ main def Test = {
5
5
// in dotty-example-project
6
6
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 = {
9
8
println(tree.show)
10
9
}
11
10
}
Original file line number Diff line number Diff line change 1
- import scala .tasty . Reflection
1
+ import scala .quoted . _
2
2
import scala .tasty .inspector ._
3
3
4
4
// Ambiguous member names
@@ -32,16 +32,16 @@ class TestInspector_Children() extends TastyInspector:
32
32
33
33
var kids : List [String ] = Nil
34
34
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)
38
38
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 . _
41
41
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 =>
45
45
kids = t.symbol.children.map(_.fullName)
46
46
47
47
case x =>
Original file line number Diff line number Diff line change 1
- import scala .tasty . Reflection
1
+ import scala .quoted . _
2
2
import scala .tasty .inspector ._
3
3
4
4
object Test {
@@ -17,6 +17,6 @@ class TestInspector_NonTasty() extends TastyInspector:
17
17
var isAlreadyLoaded : Boolean = false
18
18
var className : String = " "
19
19
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 . _
2
2
import scala .tasty .inspector ._
3
3
4
4
object Test {
@@ -9,8 +9,8 @@ object Test {
9
9
10
10
class CommentInspector extends TastyInspector {
11
11
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 . _
14
14
object Traverser extends TreeTraverser {
15
15
16
16
override def traverseTree (tree : Tree )(implicit ctx : Context ): Unit = tree match {
@@ -25,7 +25,7 @@ class CommentInspector extends TastyInspector {
25
25
}
26
26
27
27
}
28
- Traverser .traverseTree(root)(reflect.rootContext)
28
+ Traverser .traverseTree(root)
29
29
}
30
30
31
31
}
Original file line number Diff line number Diff line change 1
- import scala .tasty . Reflection
1
+ import scala .quoted . _
2
2
import scala .tasty .inspector ._
3
3
4
4
object Test {
@@ -9,8 +9,8 @@ object Test {
9
9
10
10
class DBInspector extends TastyInspector {
11
11
12
- protected 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 . _
14
14
object Traverser extends TreeTraverser {
15
15
16
16
override def traverseTree (tree : Tree )(implicit ctx : Context ): Unit = tree match {
@@ -22,7 +22,7 @@ class DBInspector extends TastyInspector {
22
22
}
23
23
24
24
}
25
- Traverser .traverseTree(root)(reflect.rootContext)
25
+ Traverser .traverseTree(root)
26
26
}
27
27
28
28
}
Original file line number Diff line number Diff line change 1
1
package scala .tasty .interpreter
2
2
3
- import scala .tasty . Reflection
3
+ import scala .quoted . _
4
4
import scala .tasty .inspector .TastyInspector
5
5
6
6
class TastyInterpreter extends TastyInspector {
7
7
8
- protected def processCompilationUnit (reflect : Reflection )(root : reflect .Tree ): Unit = {
9
- import reflect .{ _ , given _ }
8
+ protected def processCompilationUnit (using QuoteContext )(root : qctx.tasty .Tree ): Unit = {
9
+ import qctx . tasty . _
10
10
object Traverser extends TreeTraverser {
11
11
12
12
override def traverseTree (tree : Tree )(implicit ctx : Context ): Unit = tree match {
@@ -20,6 +20,6 @@ class TastyInterpreter extends TastyInspector {
20
20
super .traverseTree(tree)
21
21
}
22
22
}
23
- Traverser .traverseTree(root)(reflect.rootContext)
23
+ Traverser .traverseTree(root)
24
24
}
25
25
}
You can’t perform that action at this time.
0 commit comments