Skip to content

Commit 3224393

Browse files
committed
Rename TASTy Reflect showCode to show
With this change show on Expr and on Tree will have the same result.
1 parent d4a47aa commit 3224393

File tree

16 files changed

+50
-42
lines changed

16 files changed

+50
-42
lines changed

library/src-bootstrapped/scala/internal/quoted/Matcher.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,12 @@ object Matcher {
178178
println(
179179
s""">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
180180
|Scrutinee
181-
| ${scrutinee.showCode}
181+
| ${scrutinee.show}
182182
|
183183
|${scrutinee.showExtractors}
184184
|
185185
|did not match pattern
186-
| ${pattern.showCode}
186+
| ${pattern.show}
187187
|
188188
|${pattern.showExtractors}
189189
|
@@ -251,12 +251,12 @@ object Matcher {
251251
println(
252252
s""">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
253253
|Scrutinee
254-
| ${scrutinee.showCode}
254+
| ${scrutinee.show}
255255
|
256256
|${scrutinee.showExtractors}
257257
|
258258
|did not match pattern
259-
| ${pattern.showCode}
259+
| ${pattern.show}
260260
|
261261
|${pattern.showExtractors}
262262
|

library/src-bootstrapped/scala/tasty/reflect/QuotedOps.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ trait QuotedOps extends Core { self: Printers =>
1414

1515
/** Show a source code like representation of this expression */
1616
def show(implicit ctx: Context): String =
17-
unseal.showCode
17+
unseal.show
1818
}
1919

2020
implicit class QuotedTypeAPI[T <: AnyKind](tpe: scala.quoted.Type[T]) {
@@ -24,7 +24,7 @@ trait QuotedOps extends Core { self: Printers =>
2424

2525
/** Show a source code like representation of this type */
2626
def show(implicit ctx: Context): String =
27-
unseal.showCode
27+
unseal.show
2828
}
2929

3030
implicit class TermToQuotedAPI(term: Term) {

library/src-non-bootstrapped/scala/tasty/reflect/QuotedOps.scala

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ trait QuotedOps extends Core { self: Printers =>
1515
/** Show a source code like representation of this expression.
1616
* Will print Ansi colors if ctx.printColors is enabled.
1717
*/
18-
def show(implicit ctx: Context): String =
19-
unseal.showCode
18+
def show(implicit ctx: Context): String = unseal.show
2019
}
2120

2221
implicit class QuotedTypeAPI[T](tpe: scala.quoted.Type[T]) {
@@ -27,8 +26,7 @@ trait QuotedOps extends Core { self: Printers =>
2726
/** Show a source code like representation of this type
2827
* Will print Ansi colors if ctx.printColors is enabled.
2928
*/
30-
def show(implicit ctx: Context): String =
31-
unseal.showCode
29+
def show(implicit ctx: Context): String = unseal.show
3230
}
3331

3432
implicit class TermToQuotedAPI(term: Term) {

library/src/scala/tasty/reflect/Printers.scala

+22-12
Original file line numberDiff line numberDiff line change
@@ -24,48 +24,58 @@ trait Printers
2424
implicit class TreeShowDeco(tree: Tree) {
2525
/** Shows the tree as extractors */
2626
def showExtractors(implicit ctx: Context): String = new ExtractorsPrinter().showTree(tree)
27-
/** Shows the tree as source code */
28-
def showCode(implicit ctx: Context): String = new SourceCodePrinter().showTree(tree)
27+
/** Shows the tree as fully typed source code.
28+
* Will print Ansi colors if ctx.printColors is enabled.
29+
*/
30+
def show(implicit ctx: Context): String = new SourceCodePrinter().showTree(tree)
2931
}
3032

3133
/** Adds `show` as an extension method of a `TypeOrBounds` */
3234
implicit class TypeOrBoundsShowDeco(tpe: TypeOrBounds) {
3335
/** Shows the tree as extractors */
3436
def showExtractors(implicit ctx: Context): String = new ExtractorsPrinter().showTypeOrBounds(tpe)
35-
/** Shows the tree as source code */
36-
def showCode(implicit ctx: Context): String = new SourceCodePrinter().showTypeOrBounds(tpe)
37+
/** Shows the tree as fully typed source code.
38+
* Will print Ansi colors if ctx.printColors is enabled.
39+
*/
40+
def show(implicit ctx: Context): String = new SourceCodePrinter().showTypeOrBounds(tpe)
3741
}
3842

3943
/** Adds `show` as an extension method of a `Pattern` */
4044
implicit class PatternShowDeco(pattern: Pattern) {
4145
/** Shows the tree as extractors */
4246
def showExtractors(implicit ctx: Context): String = new ExtractorsPrinter().showPattern(pattern)
43-
/** Shows the tree as source code */
44-
def showCode(implicit ctx: Context): String = new SourceCodePrinter().showPattern(pattern)
47+
/** Shows the tree as fully typed source code.
48+
* Will print Ansi colors if ctx.printColors is enabled.
49+
*/
50+
def show(implicit ctx: Context): String = new SourceCodePrinter().showPattern(pattern)
4551
}
4652

4753
/** Adds `show` as an extension method of a `Constant` */
4854
implicit class ConstantShowDeco(const: Constant) {
4955
/** Shows the tree as extractors */
5056
def showExtractors(implicit ctx: Context): String = new ExtractorsPrinter().showConstant(const)
51-
/** Shows the tree as source code */
52-
def showCode(implicit ctx: Context): String = new SourceCodePrinter().showConstant(const)
57+
/** Shows the tree as fully typed source code.
58+
* Will print Ansi colors if ctx.printColors is enabled.
59+
*/
60+
def show(implicit ctx: Context): String = new SourceCodePrinter().showConstant(const)
5361
}
5462

5563
/** Adds `show` as an extension method of a `Symbol` */
5664
implicit class SymbolShowDeco(symbol: Symbol) {
5765
/** Shows the tree as extractors */
5866
def showExtractors(implicit ctx: Context): String = new ExtractorsPrinter().showSymbol(symbol)
59-
/** Shows the tree as source code */
60-
def showCode(implicit ctx: Context): String = new SourceCodePrinter().showSymbol(symbol)
67+
/** Shows the tree as fully typed source code */
68+
def show(implicit ctx: Context): String = new SourceCodePrinter().showSymbol(symbol)
6169
}
6270

6371
/** Adds `show` as an extension method of a `Flags` */
6472
implicit class FlagsShowDeco(flags: Flags) {
6573
/** Shows the tree as extractors */
6674
def showExtractors(implicit ctx: Context): String = new ExtractorsPrinter().showFlags(flags)
67-
/** Shows the tree as source code */
68-
def showCode(implicit ctx: Context): String = new SourceCodePrinter().showFlags(flags)
75+
/** Shows the tree as fully typed source code.
76+
* Will print Ansi colors if ctx.printColors is enabled.
77+
*/
78+
def show(implicit ctx: Context): String = new SourceCodePrinter().showFlags(flags)
6979
}
7080

7181
abstract class Printer {

tests/neg/tasty-macro-error/quoted_1.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ object Macros {
88

99
def impl(x: Expr[Any])(implicit reflect: Reflection): Expr[Unit] = {
1010
import reflect._
11-
error("here is the the argument is " + x.unseal.underlyingArgument.showCode, x.unseal.underlyingArgument.pos)
11+
error("here is the the argument is " + x.unseal.underlyingArgument.show, x.unseal.underlyingArgument.pos)
1212
'{}
1313
}
1414

tests/neg/tasty-macro-positions/quoted_1.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ object Macros {
99
def impl(x: Expr[Any])(implicit reflect: Reflection): Expr[Unit] = {
1010
import reflect._
1111
val pos = x.unseal.underlyingArgument.pos
12-
error("here is the the argument is " + x.unseal.underlyingArgument.showCode, pos)
13-
error("here (+5) is the the argument is " + x.unseal.underlyingArgument.showCode, pos.sourceFile, pos.start + 5, pos.end + 5)
12+
error("here is the the argument is " + x.unseal.underlyingArgument.show, pos)
13+
error("here (+5) is the the argument is " + x.unseal.underlyingArgument.show, pos.sourceFile, pos.start + 5, pos.end + 5)
1414
'{}
1515
}
1616

tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) {
160160
if (LOG)
161161
println(
162162
s"""#> $tag:
163-
|${tree.showCode}
163+
|${tree.show}
164164
|${tree.showExtractors}
165165
|
166166
|""".stripMargin)

tests/run-with-compiler/quote-matcher-runtime/quoted_1.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ object Macros {
1313
val res = scala.internal.quoted.Matcher.unapply[Tuple](a)(b, reflect).map { tup =>
1414
tup.toArray.toList.map {
1515
case r: Expr[_] =>
16-
s"Expr(${r.unseal.showCode})"
16+
s"Expr(${r.unseal.show})"
1717
case r: quoted.Type[_] =>
18-
s"Type(${r.unseal.showCode})"
18+
s"Type(${r.unseal.show})"
1919
}
2020
}
2121

2222
'{
23-
println("Scrutinee: " + ${a.unseal.showCode.toExpr})
24-
println("Pattern: " + ${b.unseal.showCode.toExpr})
23+
println("Scrutinee: " + ${a.unseal.show.toExpr})
24+
println("Pattern: " + ${b.unseal.show.toExpr})
2525
println("Result: " + ${res.toString.toExpr})
2626
println()
2727
}

tests/run/f-interpolation-1/FQuote_1.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ object FQuote {
4848

4949
for ((arg, part) <- allArgs.zip(parts.tail)) {
5050
if (part.startsWith("%d") && !(arg.tpe <:< definitions.IntType)) {
51-
return '{s"`${${arg.showCode}}` is not of type Int"}
51+
return '{s"`${${arg.show}}` is not of type Int"}
5252
}
5353

5454
}

tests/run/gestalt-type-toolbox-reflect/Macro_1.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ object TypeToolbox {
8989
inline def typeTag[T](x: T): String = ${typeTagImpl('[T])}
9090
private def typeTagImpl(tp: Type[_])(implicit reflect: Reflection): Expr[String] = {
9191
import reflect._
92-
val res = tp.unseal.tpe.showCode
92+
val res = tp.unseal.tpe.show
9393
res.toExpr
9494
}
9595

tests/run/inferred-repeated-result/test_1.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ object Macros {
1111

1212
val methods =
1313
tree.tpe.classSymbol.get.classMethods.map { m =>
14-
val name = m.showCode
15-
val returnType = m.tree.returnTpt.tpe.showCode
14+
val name = m.show
15+
val returnType = m.tree.returnTpt.tpe.show
1616
s"$name : $returnType"
1717
}.sorted
1818

tests/run/tasty-dealias/quoted_1.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ object Macros {
77

88
def impl[T](x: quoted.Type[T])(implicit reflect: Reflection): Expr[String] = {
99
import reflect._
10-
x.unseal.tpe.dealias.showCode.toExpr
10+
x.unseal.tpe.dealias.show.toExpr
1111
}
1212
}

tests/run/tasty-macro-positions/quoted_1.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ object Macros {
1313
def impl(x: Expr[Any])(implicit reflect: Reflection): Expr[Unit] = {
1414
import reflect._
1515
val pos = x.unseal.underlyingArgument.pos
16-
val code = x.unseal.underlyingArgument.showCode
16+
val code = x.unseal.underlyingArgument.show
1717
'{
1818
println(${posStr(reflect)(pos)})
1919
println(${code.toExpr})
@@ -23,7 +23,7 @@ object Macros {
2323
def impl2[T](x: quoted.Type[T])(implicit reflect: Reflection): Expr[Unit] = {
2424
import reflect._
2525
val pos = x.unseal.pos
26-
val code = x.unseal.showCode
26+
val code = x.unseal.show
2727
'{
2828
println(${posStr(reflect)(pos)})
2929
println(${code.toExpr})

tests/run/tasty-typeof/Macro_1.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ object Macros {
2525
assert(${(typeOf[Object] =:= definitions.ObjectType)}, "Object")
2626
assert(${(typeOf[Nothing] =:= definitions.NothingType)}, "Nothing")
2727

28-
println(${typeOf[List[Int]].showCode})
29-
println(${typeOf[Macros].showCode})
30-
println(${typeOf[Macros.type].showCode})
28+
println(${typeOf[List[Int]].show})
29+
println(${typeOf[Macros].show})
30+
println(${typeOf[Macros.type].show})
3131
}
3232
}
3333

tests/run/xml-interpolation-1/XmlQuote_1.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ object XmlQuote {
2323
// for debugging purpose
2424
def pp(tree: Tree): Unit = {
2525
println(tree.showExtractors)
26-
println(tree.showCode)
26+
println(tree.show)
2727
}
2828

2929
def liftListOfAny(lst: List[Term]): Expr[List[Any]] = lst match {

tests/run/xml-interpolation-2/XmlQuote_1.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ object XmlQuote {
2222
// for debugging purpose
2323
def pp(tree: Tree): Unit = {
2424
println(tree.showExtractors)
25-
println(tree.showCode)
25+
println(tree.show)
2626
}
2727

2828
def isSCOpsConversion(tree: Term) =

0 commit comments

Comments
 (0)