@@ -5,33 +5,32 @@ import scala.quoted._
55import dotty .tools .scaladoc .util .Escape ._
66import scala .util .matching .Regex
77
8- trait JavadocAnchorCreator :
9- self : SymOps [_] =>
8+ object JavadocAnchorCreator :
109
11- import self .q .reflect ._
10+ private def javadocPrimitives (using Quotes )(sym : quotes.reflect.Symbol ) =
11+ import quotes .reflect .*
12+ if sym == defn.IntClass then Some (" int" )
13+ else if sym == defn.FloatClass then Some (" float" )
14+ else if sym == defn.DoubleClass then Some (" double" )
15+ else if sym == defn.LongClass then Some (" long" )
16+ else if sym == defn.ByteClass then Some (" byte" )
17+ else if sym == defn.BooleanClass then Some (" boolean" )
18+ else if sym == defn.CharClass then Some (" char" )
19+ else if sym == defn.ShortClass then Some (" short" )
20+ else if sym == defn.ObjectClass then Some (" java.lang.Object" )
21+ else None
1222
13- private val javadocPrimitivesMap = Map (
14- defn.IntClass -> " int" ,
15- defn.FloatClass -> " float" ,
16- defn.DoubleClass -> " double" ,
17- defn.LongClass -> " long" ,
18- defn.ByteClass -> " byte" ,
19- defn.BooleanClass -> " boolean" ,
20- defn.CharClass -> " char" ,
21- defn.ShortClass -> " short" ,
22- defn.ObjectClass -> " java.lang.Object"
23- )
24-
25- private def transformPrimitiveType (tpe : TypeRepr ): String = tpe.classSymbol
26- .flatMap(javadocPrimitivesMap.get)
23+ private def transformPrimitiveType (using Quotes )(tpe : quotes.reflect.TypeRepr ): String = tpe.classSymbol
24+ .flatMap(javadocPrimitives)
2725 .filter(_ => ! tpe.typeSymbol.isTypeParam)
2826 .getOrElse(tpe.show)
2927
30- private def transformType (tpe : TypeRepr ): String = tpe.simplified match {
31- case AppliedType (tpe, typeList) if tpe.classSymbol.fold(false )(_ == defn.ArrayClass ) => transformType(typeList.head) + " :A"
32- case AppliedType (tpe, typeList) if tpe.classSymbol.fold(false )(_ == defn.RepeatedParamClass ) => transformType(typeList.head) + " ..."
33- case AppliedType (tpe, typeList) => transformPrimitiveType(tpe)
34- case other => transformPrimitiveType(other)
35- }
28+ private def transformType (using Quotes )(tpe : quotes.reflect.TypeRepr ): String =
29+ import quotes .reflect .*
30+ tpe.simplified match
31+ case AppliedType (tpe, typeList) if tpe.classSymbol.fold(false )(_ == defn.ArrayClass ) => transformType(typeList.head) + " :A"
32+ case AppliedType (tpe, typeList) if tpe.classSymbol.fold(false )(_ == defn.RepeatedParamClass ) => transformType(typeList.head) + " ..."
33+ case AppliedType (tpe, typeList) => transformPrimitiveType(tpe)
34+ case other => transformPrimitiveType(other)
3635
37- def getJavadocType (s : TypeRepr ) = transformType(s)
36+ def getJavadocType (using Quotes )( s : quotes.reflect. TypeRepr ) = transformType(s)
0 commit comments