@@ -6,32 +6,33 @@ import dotty.tools.scaladoc.util.Escape._
6
6
import scala .util .matching .Regex
7
7
8
8
trait JavadocAnchorCreator :
9
- self : SymOps [_] =>
10
9
11
- import self .q .reflect ._
10
+ private def javadocPrimitive (using Quotes )(sym : quotes.reflect.Symbol ): Option [String ] =
11
+ import quotes .reflect .defn
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.ShortClass then Some (" java.lang.Object" )
21
+ else None
12
22
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
- )
23
+ private def transformPrimitiveType (using Quotes )(tpe : quotes.reflect.TypeRepr ): String =
24
+ tpe.classSymbol
25
+ .filter(_ => ! tpe.typeSymbol.isTypeParam)
26
+ .flatMap(javadocPrimitive)
27
+ .getOrElse(tpe.show)
24
28
25
- private def transformPrimitiveType (tpe : TypeRepr ): String = tpe.classSymbol
26
- .flatMap(javadocPrimitivesMap.get)
27
- .filter(_ => ! tpe.typeSymbol.isTypeParam)
28
- .getOrElse(tpe.show)
29
+ private def transformType (using Quotes )(tpe : quotes.reflect.TypeRepr ): String =
30
+ import quotes .reflect .*
31
+ tpe.simplified match {
32
+ case AppliedType (tpe, typeList) if tpe.classSymbol.fold(false )(_ == defn.ArrayClass ) => transformType(typeList.head) + " :A"
33
+ case AppliedType (tpe, typeList) if tpe.classSymbol.fold(false )(_ == defn.RepeatedParamClass ) => transformType(typeList.head) + " ..."
34
+ case AppliedType (tpe, typeList) => transformPrimitiveType(tpe)
35
+ case other => transformPrimitiveType(other)
36
+ }
29
37
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
- }
36
-
37
- def getJavadocType (s : TypeRepr ) = transformType(s)
38
+ def getJavadocType (using Quotes )(s : quotes.reflect.TypeRepr ) = transformType(s)
0 commit comments