@@ -26,17 +26,14 @@ object QuoteContextImpl {
2626 def apply ()(using Context ): QuoteContext =
2727 new QuoteContextImpl (ctx)
2828
29- def showTree (tree : tpd.Tree )(using Context ): String = {
30- val qctx = QuoteContextImpl ()( using MacroExpansion .context(tree))
31- val syntaxHighlight =
32- if (ctx.settings.color.value == " always " ) SyntaxHighlight . ANSI
33- else SyntaxHighlight .plain
34- show( using qctx)(tree. asInstanceOf [qctx.reflect. Tree ], syntaxHighlight)( using ctx. asInstanceOf [ qctx.reflect.Context ] )
29+ def showDecompiledTree (tree : tpd.Tree )(using Context ): String = {
30+ val qctx : QuoteContextImpl = new QuoteContextImpl (MacroExpansion .context(tree))
31+ if ctx.settings.color.value == " always " then
32+ qctx.reflect. TreeMethodsImpl .extension_showAnsiColored(tree)
33+ else
34+ qctx.reflect.TreeMethodsImpl .extension_show(tree )
3535 }
3636
37- private def show (using qctx : QuoteContext )(tree : qctx.reflect.Tree , syntaxHighlight : SyntaxHighlight )(using qctx.reflect.Context ) =
38- tree.showWith(syntaxHighlight)
39-
4037 private [dotty] def checkScopeId (id : ScopeId )(using Context ): Unit =
4138 if (id != scopeId)
4239 throw new scala.quoted.ScopeException (" Cannot call `scala.quoted.staging.run(...)` within a macro or another `run(...)`" )
@@ -67,9 +64,9 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext:
6764 def showExtractors : String =
6865 Extractors .showTree(using QuoteContextImpl .this )(self)
6966 def show : String =
70- self.showWith (SyntaxHighlight .plain)
71- def showWith ( syntaxHighlight : SyntaxHighlight ) : String =
72- SourceCode .showTree(using QuoteContextImpl .this )(self)(syntaxHighlight )
67+ SourceCode .showTree( using QuoteContextImpl . this )(self) (SyntaxHighlight .plain)
68+ def showAnsiColored : String =
69+ SourceCode .showTree(using QuoteContextImpl .this )(self)(SyntaxHighlight . ANSI )
7370 def isExpr : Boolean =
7471 self match
7572 case TermTypeTest (self) =>
@@ -1592,10 +1589,10 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext:
15921589 Extractors .showType(using QuoteContextImpl .this )(self)
15931590
15941591 def show : String =
1595- self.showWith (SyntaxHighlight .plain)
1592+ SourceCode .showType( using QuoteContextImpl . this )(self) (SyntaxHighlight .plain)
15961593
1597- def showWith ( syntaxHighlight : SyntaxHighlight ) : String =
1598- SourceCode .showType(using QuoteContextImpl .this )(self)(syntaxHighlight )
1594+ def showAnsiColored : String =
1595+ SourceCode .showType(using QuoteContextImpl .this )(self)(SyntaxHighlight . ANSI )
15991596
16001597 def seal : scala.quoted.Type [_] =
16011598 new scala.internal.quoted.Type (Inferred (self), QuoteContextImpl .this .hashCode)
@@ -2174,9 +2171,9 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext:
21742171 def showExtractors : String =
21752172 Extractors .showConstant(using QuoteContextImpl .this )(self)
21762173 def show : String =
2177- self.showWith (SyntaxHighlight .plain)
2178- def showWith ( syntaxHighlight : SyntaxHighlight ) : String =
2179- SourceCode .showConstant(using QuoteContextImpl .this )(self)(syntaxHighlight )
2174+ SourceCode .showConstant( using QuoteContextImpl . this )(self) (SyntaxHighlight .plain)
2175+ def showAnsiColored : String =
2176+ SourceCode .showConstant(using QuoteContextImpl .this )(self)(SyntaxHighlight . ANSI )
21802177 end extension
21812178 end ConstantMethodsImpl
21822179
@@ -2397,9 +2394,9 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext:
23972394 def showExtractors : String =
23982395 Extractors .showSymbol(using QuoteContextImpl .this )(self)
23992396 def show : String =
2400- self.showWith (SyntaxHighlight .plain)
2401- def showWith ( syntaxHighlight : SyntaxHighlight ) : String =
2402- SourceCode .showSymbol(using QuoteContextImpl .this )(self)(syntaxHighlight )
2397+ SourceCode .showSymbol( using QuoteContextImpl . this )(self) (SyntaxHighlight .plain)
2398+ def showAnsiColored : String =
2399+ SourceCode .showSymbol(using QuoteContextImpl .this )(self)(SyntaxHighlight . ANSI )
24032400
24042401 end extension
24052402
@@ -2533,9 +2530,9 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext:
25332530 def showExtractors : String =
25342531 Extractors .showFlags(using QuoteContextImpl .this )(self)
25352532 def show : String =
2536- self.showWith (SyntaxHighlight .plain)
2537- def showWith ( syntaxHighlight : SyntaxHighlight ) : String =
2538- SourceCode .showFlags(using QuoteContextImpl .this )(self)(syntaxHighlight )
2533+ SourceCode .showFlags( using QuoteContextImpl . this )(self) (SyntaxHighlight .plain)
2534+ def showAnsiColored : String =
2535+ SourceCode .showFlags(using QuoteContextImpl .this )(self)(SyntaxHighlight . ANSI )
25392536 end extension
25402537 end FlagsMethodsImpl
25412538
0 commit comments