diff --git a/library/src-bootstrapped/scala/internal/quoted/Matcher.scala b/library/src-bootstrapped/scala/internal/quoted/Matcher.scala index 11c86ee33fc7..685db0f1b781 100644 --- a/library/src-bootstrapped/scala/internal/quoted/Matcher.scala +++ b/library/src-bootstrapped/scala/internal/quoted/Matcher.scala @@ -178,12 +178,12 @@ object Matcher { println( s""">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |Scrutinee - | ${scrutinee.showCode} + | ${scrutinee.show} | |${scrutinee.showExtractors} | |did not match pattern - | ${pattern.showCode} + | ${pattern.show} | |${pattern.showExtractors} | @@ -251,12 +251,12 @@ object Matcher { println( s""">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |Scrutinee - | ${scrutinee.showCode} + | ${scrutinee.show} | |${scrutinee.showExtractors} | |did not match pattern - | ${pattern.showCode} + | ${pattern.show} | |${pattern.showExtractors} | diff --git a/library/src-bootstrapped/scala/tasty/reflect/QuotedOps.scala b/library/src-bootstrapped/scala/tasty/reflect/QuotedOps.scala index 1bdacf395350..1e42d9070740 100644 --- a/library/src-bootstrapped/scala/tasty/reflect/QuotedOps.scala +++ b/library/src-bootstrapped/scala/tasty/reflect/QuotedOps.scala @@ -14,7 +14,7 @@ trait QuotedOps extends Core { self: Printers => /** Show a source code like representation of this expression */ def show(implicit ctx: Context): String = - unseal.showCode + unseal.show } implicit class QuotedTypeAPI[T <: AnyKind](tpe: scala.quoted.Type[T]) { @@ -24,7 +24,7 @@ trait QuotedOps extends Core { self: Printers => /** Show a source code like representation of this type */ def show(implicit ctx: Context): String = - unseal.showCode + unseal.show } implicit class TermToQuotedAPI(term: Term) { diff --git a/library/src-non-bootstrapped/scala/tasty/reflect/QuotedOps.scala b/library/src-non-bootstrapped/scala/tasty/reflect/QuotedOps.scala index c3dea20121f1..c3fa8502315d 100644 --- a/library/src-non-bootstrapped/scala/tasty/reflect/QuotedOps.scala +++ b/library/src-non-bootstrapped/scala/tasty/reflect/QuotedOps.scala @@ -15,8 +15,7 @@ trait QuotedOps extends Core { self: Printers => /** Show a source code like representation of this expression. * Will print Ansi colors if ctx.printColors is enabled. */ - def show(implicit ctx: Context): String = - unseal.showCode + def show(implicit ctx: Context): String = unseal.show } implicit class QuotedTypeAPI[T](tpe: scala.quoted.Type[T]) { @@ -27,8 +26,7 @@ trait QuotedOps extends Core { self: Printers => /** Show a source code like representation of this type * Will print Ansi colors if ctx.printColors is enabled. */ - def show(implicit ctx: Context): String = - unseal.showCode + def show(implicit ctx: Context): String = unseal.show } implicit class TermToQuotedAPI(term: Term) { diff --git a/library/src/scala/tasty/reflect/Printers.scala b/library/src/scala/tasty/reflect/Printers.scala index 81bb8323a44f..191abc32ec46 100644 --- a/library/src/scala/tasty/reflect/Printers.scala +++ b/library/src/scala/tasty/reflect/Printers.scala @@ -24,48 +24,58 @@ trait Printers implicit class TreeShowDeco(tree: Tree) { /** Shows the tree as extractors */ def showExtractors(implicit ctx: Context): String = new ExtractorsPrinter().showTree(tree) - /** Shows the tree as source code */ - def showCode(implicit ctx: Context): String = new SourceCodePrinter().showTree(tree) + /** Shows the tree as fully typed source code. + * Will print Ansi colors if ctx.printColors is enabled. + */ + def show(implicit ctx: Context): String = new SourceCodePrinter().showTree(tree) } /** Adds `show` as an extension method of a `TypeOrBounds` */ implicit class TypeOrBoundsShowDeco(tpe: TypeOrBounds) { /** Shows the tree as extractors */ def showExtractors(implicit ctx: Context): String = new ExtractorsPrinter().showTypeOrBounds(tpe) - /** Shows the tree as source code */ - def showCode(implicit ctx: Context): String = new SourceCodePrinter().showTypeOrBounds(tpe) + /** Shows the tree as fully typed source code. + * Will print Ansi colors if ctx.printColors is enabled. + */ + def show(implicit ctx: Context): String = new SourceCodePrinter().showTypeOrBounds(tpe) } /** Adds `show` as an extension method of a `Pattern` */ implicit class PatternShowDeco(pattern: Pattern) { /** Shows the tree as extractors */ def showExtractors(implicit ctx: Context): String = new ExtractorsPrinter().showPattern(pattern) - /** Shows the tree as source code */ - def showCode(implicit ctx: Context): String = new SourceCodePrinter().showPattern(pattern) + /** Shows the tree as fully typed source code. + * Will print Ansi colors if ctx.printColors is enabled. + */ + def show(implicit ctx: Context): String = new SourceCodePrinter().showPattern(pattern) } /** Adds `show` as an extension method of a `Constant` */ implicit class ConstantShowDeco(const: Constant) { /** Shows the tree as extractors */ def showExtractors(implicit ctx: Context): String = new ExtractorsPrinter().showConstant(const) - /** Shows the tree as source code */ - def showCode(implicit ctx: Context): String = new SourceCodePrinter().showConstant(const) + /** Shows the tree as fully typed source code. + * Will print Ansi colors if ctx.printColors is enabled. + */ + def show(implicit ctx: Context): String = new SourceCodePrinter().showConstant(const) } /** Adds `show` as an extension method of a `Symbol` */ implicit class SymbolShowDeco(symbol: Symbol) { /** Shows the tree as extractors */ def showExtractors(implicit ctx: Context): String = new ExtractorsPrinter().showSymbol(symbol) - /** Shows the tree as source code */ - def showCode(implicit ctx: Context): String = new SourceCodePrinter().showSymbol(symbol) + /** Shows the tree as fully typed source code */ + def show(implicit ctx: Context): String = new SourceCodePrinter().showSymbol(symbol) } /** Adds `show` as an extension method of a `Flags` */ implicit class FlagsShowDeco(flags: Flags) { /** Shows the tree as extractors */ def showExtractors(implicit ctx: Context): String = new ExtractorsPrinter().showFlags(flags) - /** Shows the tree as source code */ - def showCode(implicit ctx: Context): String = new SourceCodePrinter().showFlags(flags) + /** Shows the tree as fully typed source code. + * Will print Ansi colors if ctx.printColors is enabled. + */ + def show(implicit ctx: Context): String = new SourceCodePrinter().showFlags(flags) } abstract class Printer { diff --git a/tests/neg/tasty-macro-error/quoted_1.scala b/tests/neg/tasty-macro-error/quoted_1.scala index fc1808e5ff9d..1df04315c127 100644 --- a/tests/neg/tasty-macro-error/quoted_1.scala +++ b/tests/neg/tasty-macro-error/quoted_1.scala @@ -8,7 +8,7 @@ object Macros { def impl(x: Expr[Any])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ - error("here is the the argument is " + x.unseal.underlyingArgument.showCode, x.unseal.underlyingArgument.pos) + error("here is the the argument is " + x.unseal.underlyingArgument.show, x.unseal.underlyingArgument.pos) '{} } diff --git a/tests/neg/tasty-macro-positions/quoted_1.scala b/tests/neg/tasty-macro-positions/quoted_1.scala index fd5c20a6f58c..b8c4232310a6 100644 --- a/tests/neg/tasty-macro-positions/quoted_1.scala +++ b/tests/neg/tasty-macro-positions/quoted_1.scala @@ -9,8 +9,8 @@ object Macros { def impl(x: Expr[Any])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ val pos = x.unseal.underlyingArgument.pos - error("here is the the argument is " + x.unseal.underlyingArgument.showCode, pos) - error("here (+5) is the the argument is " + x.unseal.underlyingArgument.showCode, pos.sourceFile, pos.start + 5, pos.end + 5) + error("here is the the argument is " + x.unseal.underlyingArgument.show, pos) + error("here (+5) is the the argument is " + x.unseal.underlyingArgument.show, pos.sourceFile, pos.start + 5, pos.end + 5) '{} } diff --git a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala index 71a15e540f9b..5cfe3c16645c 100644 --- a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala +++ b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala @@ -160,7 +160,7 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) { if (LOG) println( s"""#> $tag: - |${tree.showCode} + |${tree.show} |${tree.showExtractors} | |""".stripMargin) diff --git a/tests/run-with-compiler/quote-matcher-runtime/quoted_1.scala b/tests/run-with-compiler/quote-matcher-runtime/quoted_1.scala index cb3ced71fd61..5204b23e35c8 100644 --- a/tests/run-with-compiler/quote-matcher-runtime/quoted_1.scala +++ b/tests/run-with-compiler/quote-matcher-runtime/quoted_1.scala @@ -13,15 +13,15 @@ object Macros { val res = scala.internal.quoted.Matcher.unapply[Tuple](a)(b, reflect).map { tup => tup.toArray.toList.map { case r: Expr[_] => - s"Expr(${r.unseal.showCode})" + s"Expr(${r.unseal.show})" case r: quoted.Type[_] => - s"Type(${r.unseal.showCode})" + s"Type(${r.unseal.show})" } } '{ - println("Scrutinee: " + ${a.unseal.showCode.toExpr}) - println("Pattern: " + ${b.unseal.showCode.toExpr}) + println("Scrutinee: " + ${a.unseal.show.toExpr}) + println("Pattern: " + ${b.unseal.show.toExpr}) println("Result: " + ${res.toString.toExpr}) println() } diff --git a/tests/run/f-interpolation-1/FQuote_1.scala b/tests/run/f-interpolation-1/FQuote_1.scala index 159b22606ab1..29d1b49ad38a 100644 --- a/tests/run/f-interpolation-1/FQuote_1.scala +++ b/tests/run/f-interpolation-1/FQuote_1.scala @@ -48,7 +48,7 @@ object FQuote { for ((arg, part) <- allArgs.zip(parts.tail)) { if (part.startsWith("%d") && !(arg.tpe <:< definitions.IntType)) { - return '{s"`${${arg.showCode}}` is not of type Int"} + return '{s"`${${arg.show}}` is not of type Int"} } } diff --git a/tests/run/gestalt-type-toolbox-reflect/Macro_1.scala b/tests/run/gestalt-type-toolbox-reflect/Macro_1.scala index 52d5011e4fe6..888b6e66cd97 100644 --- a/tests/run/gestalt-type-toolbox-reflect/Macro_1.scala +++ b/tests/run/gestalt-type-toolbox-reflect/Macro_1.scala @@ -89,7 +89,7 @@ object TypeToolbox { inline def typeTag[T](x: T): String = ${typeTagImpl('[T])} private def typeTagImpl(tp: Type[_])(implicit reflect: Reflection): Expr[String] = { import reflect._ - val res = tp.unseal.tpe.showCode + val res = tp.unseal.tpe.show res.toExpr } diff --git a/tests/run/inferred-repeated-result/test_1.scala b/tests/run/inferred-repeated-result/test_1.scala index 1d451768bcd3..e1e2404a8555 100644 --- a/tests/run/inferred-repeated-result/test_1.scala +++ b/tests/run/inferred-repeated-result/test_1.scala @@ -11,8 +11,8 @@ object Macros { val methods = tree.tpe.classSymbol.get.classMethods.map { m => - val name = m.showCode - val returnType = m.tree.returnTpt.tpe.showCode + val name = m.show + val returnType = m.tree.returnTpt.tpe.show s"$name : $returnType" }.sorted diff --git a/tests/run/tasty-dealias/quoted_1.scala b/tests/run/tasty-dealias/quoted_1.scala index 94f36666a45a..6db89647e58a 100644 --- a/tests/run/tasty-dealias/quoted_1.scala +++ b/tests/run/tasty-dealias/quoted_1.scala @@ -7,6 +7,6 @@ object Macros { def impl[T](x: quoted.Type[T])(implicit reflect: Reflection): Expr[String] = { import reflect._ - x.unseal.tpe.dealias.showCode.toExpr + x.unseal.tpe.dealias.show.toExpr } } diff --git a/tests/run/tasty-macro-positions/quoted_1.scala b/tests/run/tasty-macro-positions/quoted_1.scala index a21e2fafdb73..f8cb071a9bee 100644 --- a/tests/run/tasty-macro-positions/quoted_1.scala +++ b/tests/run/tasty-macro-positions/quoted_1.scala @@ -13,7 +13,7 @@ object Macros { def impl(x: Expr[Any])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ val pos = x.unseal.underlyingArgument.pos - val code = x.unseal.underlyingArgument.showCode + val code = x.unseal.underlyingArgument.show '{ println(${posStr(reflect)(pos)}) println(${code.toExpr}) @@ -23,7 +23,7 @@ object Macros { def impl2[T](x: quoted.Type[T])(implicit reflect: Reflection): Expr[Unit] = { import reflect._ val pos = x.unseal.pos - val code = x.unseal.showCode + val code = x.unseal.show '{ println(${posStr(reflect)(pos)}) println(${code.toExpr}) diff --git a/tests/run/tasty-typeof/Macro_1.scala b/tests/run/tasty-typeof/Macro_1.scala index d3ff423a0124..365f02a62d0d 100644 --- a/tests/run/tasty-typeof/Macro_1.scala +++ b/tests/run/tasty-typeof/Macro_1.scala @@ -25,9 +25,9 @@ object Macros { assert(${(typeOf[Object] =:= definitions.ObjectType)}, "Object") assert(${(typeOf[Nothing] =:= definitions.NothingType)}, "Nothing") - println(${typeOf[List[Int]].showCode}) - println(${typeOf[Macros].showCode}) - println(${typeOf[Macros.type].showCode}) + println(${typeOf[List[Int]].show}) + println(${typeOf[Macros].show}) + println(${typeOf[Macros.type].show}) } } diff --git a/tests/run/xml-interpolation-1/XmlQuote_1.scala b/tests/run/xml-interpolation-1/XmlQuote_1.scala index 38506222fb0c..0e87dd04f1e6 100644 --- a/tests/run/xml-interpolation-1/XmlQuote_1.scala +++ b/tests/run/xml-interpolation-1/XmlQuote_1.scala @@ -23,7 +23,7 @@ object XmlQuote { // for debugging purpose def pp(tree: Tree): Unit = { println(tree.showExtractors) - println(tree.showCode) + println(tree.show) } def liftListOfAny(lst: List[Term]): Expr[List[Any]] = lst match { diff --git a/tests/run/xml-interpolation-2/XmlQuote_1.scala b/tests/run/xml-interpolation-2/XmlQuote_1.scala index 02c44f086a8e..78d92f8c6293 100644 --- a/tests/run/xml-interpolation-2/XmlQuote_1.scala +++ b/tests/run/xml-interpolation-2/XmlQuote_1.scala @@ -22,7 +22,7 @@ object XmlQuote { // for debugging purpose def pp(tree: Tree): Unit = { println(tree.showExtractors) - println(tree.showCode) + println(tree.show) } def isSCOpsConversion(tree: Term) =