11package dotty .tastydoc
22
3- import scala .tasty . Reflection
3+ import scala .quoted . _
44import dotty .tastydoc .comment .{CommentParser , CommentCleaner , Comment , WikiComment , MarkdownComment }
55import dotty .tastydoc .references ._
66import dotty .tastydoc .representations ._
77
88/** A trait containing useful methods for extracting information from the reflect API */
99trait TastyExtractor extends TastyTypeConverter with CommentParser with CommentCleaner {
10- def extractPath (reflect : Reflection )(symbol : reflect .Symbol ) : List [String ] = {
11- import reflect .{ given _ , _ }
10+ def extractPath (using QuoteContext )(symbol : qctx.tasty .Symbol ) : List [String ] = {
11+ import qctx . tasty . _
1212
1313 val pathArray = symbol.show.split(" \\ ." ) // NOTE: this should print w/o colors, inspect afterwards
1414 pathArray.iterator.slice(0 , pathArray.length - 1 ).toList
1515 }
1616
17- def extractModifiers (reflect : Reflection )(flags : reflect. Flags , privateWithin : Option [reflect. Type ], protectedWithin : Option [reflect .Type ]) : (List [String ], Option [Reference ], Option [Reference ]) = {
18- import reflect .{ given _ , _ }
17+ def extractModifiers (using QuoteContext )(flags : qctx.tasty. Flags , privateWithin : Option [qctx.tasty. Type ], protectedWithin : Option [qctx.tasty .Type ]) : (List [String ], Option [Reference ], Option [Reference ]) = {
18+ import qctx . tasty . _
1919
2020 (((if (flags.is(Flags .Override )) " override" else " " ) ::
2121 (if (flags.is(Flags .Private )) " private" else " " )::
@@ -30,18 +30,16 @@ trait TastyExtractor extends TastyTypeConverter with CommentParser with CommentC
3030 Nil ) filter (_ != " " ),
3131
3232 privateWithin match {
33- case Some (t) => Some (convertTypeToReference(reflect)( t))
33+ case Some (t) => Some (convertTypeToReference(t))
3434 case None => None
3535 },
3636 protectedWithin match {
37- case Some (t) => Some (convertTypeToReference(reflect)( t))
37+ case Some (t) => Some (convertTypeToReference(t))
3838 case None => None
3939 })
4040 }
4141
42- def extractComments (reflect : Reflection )(comment : Option [reflect.Comment ], rep : Representation ) : (Map [String , EmulatedPackageRepresentation ], String ) => Option [Comment ] = {
43- import reflect .{given _ , _ }
44-
42+ def extractComments (using QuoteContext )(comment : Option [qctx.tasty.Comment ], rep : Representation ) : (Map [String , EmulatedPackageRepresentation ], String ) => Option [Comment ] = {
4543 comment match {
4644 case Some (com) =>
4745 (packages, userDocSyntax) => {
@@ -58,13 +56,13 @@ trait TastyExtractor extends TastyTypeConverter with CommentParser with CommentC
5856 }
5957 }
6058
61- def extractClassMembers (reflect : Reflection )(body : List [reflect. Statement ], symbol : reflect .Symbol , parentRepresentation : Some [Representation ])(using mutablePackagesMap : scala.collection.mutable.HashMap [String , EmulatedPackageRepresentation ]) : List [Representation with Modifiers ] = {
62- import reflect .{ given _ , _ }
59+ def extractClassMembers (using QuoteContext )(body : List [qctx.tasty. Statement ], symbol : qctx.tasty .Symbol , parentRepresentation : Some [Representation ])(using mutablePackagesMap : scala.collection.mutable.HashMap [String , EmulatedPackageRepresentation ]) : List [Representation with Modifiers ] = {
60+ import qctx . tasty . _
6361
6462 /** Filter fields which shouldn't be displayed in the doc
6563 */
66- def filterSymbol (symbol : reflect. Symbol ): Boolean = {
67- val ownerPath = extractPath(reflect)( symbol.owner)
64+ def filterSymbol (symbol : Symbol ): Boolean = {
65+ val ownerPath = extractPath(symbol.owner)
6866
6967 ! symbol.flags.is(Flags .Synthetic ) &&
7068 ! symbol.flags.is(Flags .Artifact ) &&
@@ -79,16 +77,16 @@ trait TastyExtractor extends TastyTypeConverter with CommentParser with CommentC
7977 case _ : ValDef => None // No val/var, they are appended with symbol.fields below
8078 case _ : Inlined => None // Inlined aren't desirable members
8179 case x => Some (x)
82- }.filter(x => filterSymbol(x.symbol)).map(convertToRepresentation(reflect)( _, parentRepresentation)) ++
83- symbol.methods.filter(x => filterSymbol(x)).map{x => convertToRepresentation(reflect)( x.tree, parentRepresentation)} ++
80+ }.filter(x => filterSymbol(x.symbol)).map(convertToRepresentation(_, parentRepresentation)) ++
81+ symbol.methods.filter(x => filterSymbol(x)).map{x => convertToRepresentation(x.tree, parentRepresentation)} ++
8482 symbol.fields.filter { x =>
8583 filterSymbol(x)
8684 }.flatMap {
8785 case x if x.isValDef => Some (x)
88- // case reflect .IsValDefSymbol(x) => Some(x)
86+ // case qctx.tasty .IsValDefSymbol(x) => Some(x)
8987 case _ => None
9088 }.map { x =>
91- convertToRepresentation(reflect)( x.tree, parentRepresentation)
89+ convertToRepresentation(x.tree, parentRepresentation)
9290 }
9391 )
9492 .flatMap{
@@ -98,12 +96,12 @@ trait TastyExtractor extends TastyTypeConverter with CommentParser with CommentC
9896 .sortBy(_.name)
9997 }
10098
101- def extractParents (reflect : Reflection )(parents : List [reflect .Tree ]): List [Reference ] = {
102- import reflect .{ given _ , _ }
99+ def extractParents (using QuoteContext )(parents : List [qctx.tasty .Tree ]): List [Reference ] = {
100+ import qctx . tasty . _
103101
104102 val parentsReferences = parents.map{
105- case c : TypeTree => convertTypeToReference(reflect)( c.tpe)
106- case c : Term => convertTypeToReference(reflect)( c.tpe)
103+ case c : TypeTree => convertTypeToReference(c.tpe)
104+ case c : Term => convertTypeToReference(c.tpe)
107105 case _ => throw Exception (" Unhandeld case in parents. Please open an issue." )
108106 }
109107
@@ -117,12 +115,12 @@ trait TastyExtractor extends TastyTypeConverter with CommentParser with CommentC
117115 *
118116 * @return (is case, is a trait, is an object, the kind as a String)
119117 */
120- def extractKind (reflect : Reflection )(flags : reflect .Flags ): (Boolean , Boolean , Boolean , String ) = {
121- import reflect .{ given _ , _ }
118+ def extractKind (using QuoteContext )(flags : qctx.tasty .Flags ): (Boolean , Boolean , Boolean , String ) = {
119+ import qctx . tasty . _
122120
123- val isCase = flags.is(reflect. Flags .Case )
124- val isTrait = flags.is(reflect. Flags .Trait )
125- val isObject = flags.is(reflect. Flags .Object )
121+ val isCase = flags.is(Flags .Case )
122+ val isTrait = flags.is(Flags .Trait )
123+ val isObject = flags.is(Flags .Object )
126124 val kind = {
127125 if (isTrait){
128126 " trait"
@@ -142,38 +140,38 @@ trait TastyExtractor extends TastyTypeConverter with CommentParser with CommentC
142140 (isCase, isTrait, isObject, kind)
143141 }
144142
145- def extractCompanion (reflect : Reflection )(companionModule : Option [reflect. Symbol ], companionClass : Option [reflect .Symbol ], companionIsObject : Boolean ): Option [CompanionReference ] = {
146- import reflect .{ given _ , _ }
143+ def extractCompanion (using QuoteContext )(companionModule : Option [qctx.tasty. Symbol ], companionClass : Option [qctx.tasty .Symbol ], companionIsObject : Boolean ): Option [CompanionReference ] = {
144+ import qctx . tasty . _
147145
148146 if (companionIsObject){
149147 companionModule match {
150148 case Some (c) =>
151- val path = extractPath(reflect)( c)
152- val (_, _, _, kind) = extractKind(reflect)( c.flags)
149+ val path = extractPath(c)
150+ val (_, _, _, kind) = extractKind(c.flags)
153151 Some (CompanionReference (c.name + " $" , path.mkString(" /" , " /" , " " ), kind))
154152 case None => None
155153 }
156154 }else {
157155 companionClass match {
158156 case Some (c) =>
159- val path = extractPath(reflect)( c)
160- val (_, _, _, kind) = extractKind(reflect)( c.flags)
157+ val path = extractPath(c)
158+ val (_, _, _, kind) = extractKind(c.flags)
161159 Some (CompanionReference (c.name, path.mkString(" /" , " /" , " " ), kind))
162160 case None => None
163161 }
164162 }
165163 }
166164
167- def extractAnnotations (reflect : Reflection )(annots : List [reflect .Term ]): List [TypeReference ] = {
168- import reflect .{ given _ , _ }
165+ def extractAnnotations (using QuoteContext )(annots : List [qctx.tasty .Term ]): List [TypeReference ] = {
166+ import qctx . tasty . _
169167
170168 def keepAnnot (label : String , link : String ): Boolean = {
171169 ! (label == " SourceFile" && link == " /internal" ) &&
172170 ! (label == " Child" && link == " /internal" )
173171 }
174172
175173 annots.flatMap{a =>
176- convertTypeToReference(reflect)( a.tpe) match {
174+ convertTypeToReference(a.tpe) match {
177175 case ref@ TypeReference (label, link, _, _) if keepAnnot(label, link) => Some (ref)
178176 case _ => None
179177 }
0 commit comments