@@ -24,36 +24,67 @@ trait Printers
24
24
with TypeOrBoundsOps {
25
25
26
26
/** Adds `show` as an extension method of a `Tree` */
27
- implicit def TreeShowDeco (tree : Tree ): ShowAPI
27
+ implicit class TreeShowDeco (tree : Tree ) {
28
+ /** Shows the tree as extractors */
29
+ def show (implicit ctx : Context ): String = new ExtractorsPrinter ().showTree(tree)
30
+ /** Shows the tree as source code */
31
+ def showCode (implicit ctx : Context ): String = new SourceCodePrinter ().showTree(tree)
32
+ }
28
33
29
34
/** Adds `show` as an extension method of a `TypeOrBoundsTree` */
30
- implicit def TypeOrBoundsTreeShowDeco (tpt : TypeOrBoundsTree ): ShowAPI
35
+ implicit class TypeOrBoundsTreeShowDeco (tpt : TypeOrBoundsTree ) {
36
+ /** Shows the tree as extractors */
37
+ def show (implicit ctx : Context ): String = new ExtractorsPrinter ().showTypeOrBoundsTree(tpt)
38
+ /** Shows the tree as source code */
39
+ def showCode (implicit ctx : Context ): String = new SourceCodePrinter ().showTypeOrBoundsTree(tpt)
40
+ }
31
41
32
42
/** Adds `show` as an extension method of a `TypeOrBounds` */
33
- implicit def TypeOrBoundsShowDeco (tpt : TypeOrBounds ): ShowAPI
43
+ implicit class TypeOrBoundsShowDeco (tpe : TypeOrBounds ) {
44
+ /** Shows the tree as extractors */
45
+ def show (implicit ctx : Context ): String = new ExtractorsPrinter ().showTypeOrBounds(tpe)
46
+ /** Shows the tree as source code */
47
+ def showCode (implicit ctx : Context ): String = new SourceCodePrinter ().showTypeOrBounds(tpe)
48
+ }
34
49
35
50
/** Adds `show` as an extension method of a `CaseDef` */
36
- implicit def CaseDefShowDeco (caseDef : CaseDef ): ShowAPI
51
+ implicit class CaseDefShowDeco (caseDef : CaseDef ) {
52
+ /** Shows the tree as extractors */
53
+ def show (implicit ctx : Context ): String = new ExtractorsPrinter ().showCaseDef(caseDef)
54
+ /** Shows the tree as source code */
55
+ def showCode (implicit ctx : Context ): String = new SourceCodePrinter ().showCaseDef(caseDef)
56
+ }
37
57
38
58
/** Adds `show` as an extension method of a `Pattern` */
39
- implicit def PatternShowDeco (pattern : Pattern ): ShowAPI
59
+ implicit class PatternShowDeco (pattern : Pattern ) {
60
+ /** Shows the tree as extractors */
61
+ def show (implicit ctx : Context ): String = new ExtractorsPrinter ().showPattern(pattern)
62
+ /** Shows the tree as source code */
63
+ def showCode (implicit ctx : Context ): String = new SourceCodePrinter ().showPattern(pattern)
64
+ }
40
65
41
66
/** Adds `show` as an extension method of a `Constant` */
42
- implicit def ConstantShowDeco (const : Constant ): ShowAPI
67
+ implicit class ConstantShowDeco (const : Constant ) {
68
+ /** Shows the tree as extractors */
69
+ def show (implicit ctx : Context ): String = new ExtractorsPrinter ().showConstant(const)
70
+ /** Shows the tree as source code */
71
+ def showCode (implicit ctx : Context ): String = new SourceCodePrinter ().showConstant(const)
72
+ }
43
73
44
74
/** Adds `show` as an extension method of a `Symbol` */
45
- implicit def SymbolShowDeco (symbol : Symbol ): ShowAPI
75
+ implicit class SymbolShowDeco (symbol : Symbol ) {
76
+ /** Shows the tree as extractors */
77
+ def show (implicit ctx : Context ): String = new ExtractorsPrinter ().showSymbol(symbol)
78
+ /** Shows the tree as source code */
79
+ def showCode (implicit ctx : Context ): String = new SourceCodePrinter ().showSymbol(symbol)
80
+ }
46
81
47
82
/** Adds `show` as an extension method of a `Flags` */
48
- implicit def FlagsShowDeco (flags : Flags ): ShowAPI
49
-
50
- /** Define `show` as method */
51
- trait ShowAPI {
83
+ implicit class FlagsShowDeco (flags : Flags ) {
52
84
/** Shows the tree as extractors */
53
- def show (implicit ctx : Context ): String
54
-
85
+ def show (implicit ctx : Context ): String = new ExtractorsPrinter ().showFlags(flags)
55
86
/** Shows the tree as source code */
56
- def showCode (implicit ctx : Context ): String
87
+ def showCode (implicit ctx : Context ): String = new SourceCodePrinter ().showFlags(flags)
57
88
}
58
89
59
90
abstract class Printer {
0 commit comments