From 7933275c1bafe69eccaa1e85f81aa01eaafac6b4 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Thu, 4 Apr 2019 13:23:49 +0200 Subject: [PATCH] Rename TASTy reflect show to showExtractors This renaming is to avoid confusion with the `quote.{Expr|Type}.show` method which shows the source representation of the code. --- .../src/scala/tasty/reflect/Printers.scala | 26 ++++++++-------- .../tasty-definitions-2/Macro_1.scala | 6 ++-- .../tasty-definitions-3/Macro_1.scala | 6 ++-- .../tasty-extractors-owners/quoted_1.scala | 4 +-- .../tasty-load-tree-1/quoted_1.scala | 6 ++-- .../tasty-load-tree-2/quoted_1.scala | 6 ++-- .../interpreter/TreeInterpreter.scala | 4 +-- .../tasty-consumer/Test.scala | 2 +- tests/run/f-interpolation-1/FQuote_1.scala | 2 +- tests/run/i5119/Macro_1.scala | 2 +- tests/run/i5119b/Macro_1.scala | 2 +- .../run/tasty-argument-tree-1/quoted_1.scala | 4 +-- tests/run/tasty-definitions-1/quoted_1.scala | 30 +++++++++---------- tests/run/tasty-extractors-1/quoted_1.scala | 4 +-- tests/run/tasty-extractors-2/quoted_1.scala | 4 +-- tests/run/tasty-extractors-3/quoted_1.scala | 4 +-- .../run/tasty-extractors-types/quoted_1.scala | 4 +-- .../run/xml-interpolation-1/XmlQuote_1.scala | 4 +-- .../run/xml-interpolation-2/XmlQuote_1.scala | 2 +- 19 files changed, 61 insertions(+), 61 deletions(-) diff --git a/library/src/scala/tasty/reflect/Printers.scala b/library/src/scala/tasty/reflect/Printers.scala index 1680f8f5335c..ead0bffba496 100644 --- a/library/src/scala/tasty/reflect/Printers.scala +++ b/library/src/scala/tasty/reflect/Printers.scala @@ -24,7 +24,7 @@ trait Printers /** Adds `show` as an extension method of a `Tree` */ implicit class TreeShowDeco(tree: Tree) { /** Shows the tree as extractors */ - def show(implicit ctx: Context): String = new ExtractorsPrinter().showTree(tree) + 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) } @@ -32,7 +32,7 @@ trait Printers /** Adds `show` as an extension method of a `TypeOrBounds` */ implicit class TypeOrBoundsShowDeco(tpe: TypeOrBounds) { /** Shows the tree as extractors */ - def show(implicit ctx: Context): String = new ExtractorsPrinter().showTypeOrBounds(tpe) + 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) } @@ -40,7 +40,7 @@ trait Printers /** Adds `show` as an extension method of a `Pattern` */ implicit class PatternShowDeco(pattern: Pattern) { /** Shows the tree as extractors */ - def show(implicit ctx: Context): String = new ExtractorsPrinter().showPattern(pattern) + 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) } @@ -48,7 +48,7 @@ trait Printers /** Adds `show` as an extension method of a `Constant` */ implicit class ConstantShowDeco(const: Constant) { /** Shows the tree as extractors */ - def show(implicit ctx: Context): String = new ExtractorsPrinter().showConstant(const) + 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) } @@ -56,7 +56,7 @@ trait Printers /** Adds `show` as an extension method of a `Symbol` */ implicit class SymbolShowDeco(symbol: Symbol) { /** Shows the tree as extractors */ - def show(implicit ctx: Context): String = new ExtractorsPrinter().showSymbol(symbol) + 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) } @@ -64,7 +64,7 @@ trait Printers /** Adds `show` as an extension method of a `Flags` */ implicit class FlagsShowDeco(flags: Flags) { /** Shows the tree as extractors */ - def show(implicit ctx: Context): String = new ExtractorsPrinter().showFlags(flags) + 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) } @@ -598,7 +598,7 @@ trait Printers case IsTerm(Select(IsNew(newTree), _)) => printType(newTree.tpe)(Some(cdef.symbol)) case IsTerm(parent) => - throw new MatchError(parent.show) + throw new MatchError(parent.showExtractors) } def printSeparated(list: List[Tree /* Term | TypeTree */]): Unit = list match { @@ -937,7 +937,7 @@ trait Printers printTypeTree(tpt) case _ => - throw new MatchError(tree.show) + throw new MatchError(tree.showExtractors) } @@ -1320,7 +1320,7 @@ trait Printers case Ident("unapply" | "unapplySeq") => this += fun.symbol.owner.fullName.stripSuffix("$") case _ => - throw new MatchError(fun.show) + throw new MatchError(fun.showExtractors) } inParens(printPatterns(patterns, ", ")) @@ -1332,7 +1332,7 @@ trait Printers printTypeOrBoundsTree(tpt) case _ => - throw new MatchError(pattern.show) + throw new MatchError(pattern.showExtractors) } @@ -1457,7 +1457,7 @@ trait Printers } case _ => - throw new MatchError(tree.show) + throw new MatchError(tree.showExtractors) } @@ -1612,7 +1612,7 @@ trait Printers this += highlightTypeDef("this", color) case _ => - throw new MatchError(tpe.show) + throw new MatchError(tpe.showExtractors) } def printImportSelector(sel: ImportSelector): Buffer = sel match { @@ -1647,7 +1647,7 @@ trait Printers case Type.TypeRef("forceInline", Types.ScalaPackage()) => false case _ => true } - case x => throw new MatchError(x.show) + case x => throw new MatchError(x.showExtractors) } printAnnotations(annots) if (annots.nonEmpty) this += " " diff --git a/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala b/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala index c702ca60353c..016997e12c3e 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala @@ -10,9 +10,9 @@ object Foo { def inspectBodyImpl(x: Expr[Int])(implicit reflect: Reflection): Expr[String] = { import reflect._ def definitionString(tree: Tree): Expr[String] = tree.symbol match { - case IsDefDefSymbol(sym) => sym.tree.show - case IsValDefSymbol(sym) => sym.tree.show - case IsBindSymbol(sym) => sym.tree.show + case IsDefDefSymbol(sym) => sym.tree.showExtractors + case IsValDefSymbol(sym) => sym.tree.showExtractors + case IsBindSymbol(sym) => sym.tree.showExtractors } x.unseal match { case Inlined(None, Nil, arg) => definitionString(arg) diff --git a/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala b/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala index 92aae2365f14..d32df868176f 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala @@ -10,9 +10,9 @@ object Foo { def inspectBodyImpl(x: Expr[Int])(implicit reflect: Reflection): Expr[String] = { import reflect._ def definitionString(tree: Tree): Expr[String] = tree.symbol match { - case IsDefDefSymbol(sym) => sym.tree.show - case IsValDefSymbol(sym) => sym.tree.show - case IsBindSymbol(sym) => sym.tree.show + case IsDefDefSymbol(sym) => sym.tree.showExtractors + case IsValDefSymbol(sym) => sym.tree.showExtractors + case IsBindSymbol(sym) => sym.tree.showExtractors } x.unseal match { case Inlined(None, Nil, arg) => definitionString(arg) diff --git a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala index c80ce9fc6d19..7d61ab585773 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala @@ -28,12 +28,12 @@ object Macros { case IsDefinition(tree @ DefDef(name, _, _, _, _)) => buff.append(name) buff.append("\n") - buff.append(tree.symbol.owner.treeOpt.get.show) + buff.append(tree.symbol.owner.treeOpt.get.showExtractors) buff.append("\n\n") case IsDefinition(tree @ ValDef(name, _, _)) => buff.append(name) buff.append("\n") - buff.append(tree.symbol.owner.treeOpt.get.show) + buff.append(tree.symbol.owner.treeOpt.get.showExtractors) buff.append("\n\n") case _ => } diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala index af0c1b393961..fb6911f7e2f3 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala @@ -11,9 +11,9 @@ object Foo { import reflect._ def definitionString(tree: Tree): Expr[String] = tree.symbol match { - case IsClassDefSymbol(sym) => sym.tree.show.toExpr - case IsDefDefSymbol(sym) => sym.tree.show.toExpr - case IsValDefSymbol(sym) => sym.tree.show.toExpr + case IsClassDefSymbol(sym) => sym.tree.showExtractors.toExpr + case IsDefDefSymbol(sym) => sym.tree.showExtractors.toExpr + case IsValDefSymbol(sym) => sym.tree.showExtractors.toExpr case _ => '{"NO DEFINTION"} } diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala index 3019372e91e6..93e7277adcf6 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala @@ -11,9 +11,9 @@ object Foo { import reflect._ def definitionString(tree: Tree): Expr[String] = tree.symbol match { - case IsClassDefSymbol(sym) => sym.tree.show.toExpr - case IsDefDefSymbol(sym) => sym.tree.show.toExpr - case IsValDefSymbol(sym) => sym.tree.show.toExpr + case IsClassDefSymbol(sym) => sym.tree.showExtractors.toExpr + case IsDefDefSymbol(sym) => sym.tree.showExtractors.toExpr + case IsValDefSymbol(sym) => sym.tree.showExtractors.toExpr case _ => '{"NO DEFINTION"} } 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 f48093443e3b..71a15e540f9b 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 @@ -152,7 +152,7 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) { case Typed(expr, _) => log("", tree)(eval(expr)) case Repeated(elems, _) => log("", tree)(interpretRepeated(elems.map(elem => eval(elem)))) - case _ => throw new MatchError(tree.show) + case _ => throw new MatchError(tree.showExtractors) } } @@ -161,7 +161,7 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) { println( s"""#> $tag: |${tree.showCode} - |${tree.show} + |${tree.showExtractors} | |""".stripMargin) thunk diff --git a/tests/run-with-compiler/tasty-consumer/Test.scala b/tests/run-with-compiler/tasty-consumer/Test.scala index 6bfcb94d453a..8a803c68d8c4 100644 --- a/tests/run-with-compiler/tasty-consumer/Test.scala +++ b/tests/run-with-compiler/tasty-consumer/Test.scala @@ -15,7 +15,7 @@ class DBConsumer extends TastyConsumer { override def traverseTree(tree: Tree)(implicit ctx: Context): Unit = tree match { case IsDefinition(tree) => - println(tree.show) + println(tree.showExtractors) super.traverseTree(tree) case tree => super.traverseTree(tree) diff --git a/tests/run/f-interpolation-1/FQuote_1.scala b/tests/run/f-interpolation-1/FQuote_1.scala index afd57ad15d48..159b22606ab1 100644 --- a/tests/run/f-interpolation-1/FQuote_1.scala +++ b/tests/run/f-interpolation-1/FQuote_1.scala @@ -40,7 +40,7 @@ object FQuote { values.forall(isStringConstant) => values.collect { case Literal(Constant.String(value)) => value } case tree => - throw new QuoteError(s"String literal expected, but ${tree.show} found") + throw new QuoteError(s"String literal expected, but ${tree.showExtractors} found") } // [a0, ...]: Any* diff --git a/tests/run/i5119/Macro_1.scala b/tests/run/i5119/Macro_1.scala index 41039c6f69ee..6915a604267b 100644 --- a/tests/run/i5119/Macro_1.scala +++ b/tests/run/i5119/Macro_1.scala @@ -9,6 +9,6 @@ object Macro { implicit inline def XmlQuote(sc: => StringContext): StringContextOps = new StringContextOps(sc) def impl(sc: Expr[StringContext], args: Expr[Seq[Any]])(implicit reflect: Reflection): Expr[String] = { import reflect._ - (sc.unseal.underlyingArgument.show + "\n" + args.unseal.underlyingArgument.show) + (sc.unseal.underlyingArgument.showExtractors + "\n" + args.unseal.underlyingArgument.showExtractors) } } diff --git a/tests/run/i5119b/Macro_1.scala b/tests/run/i5119b/Macro_1.scala index 8be92780a9e2..7c251e549246 100644 --- a/tests/run/i5119b/Macro_1.scala +++ b/tests/run/i5119b/Macro_1.scala @@ -9,7 +9,7 @@ object Macro { def impl(arg1: Expr[Any], arg2: Expr[Any])(implicit reflect: Reflection): Expr[String] = { import reflect._ - (arg1.unseal.underlyingArgument.show + "\n" + arg2.unseal.underlyingArgument.show) + (arg1.unseal.underlyingArgument.showExtractors + "\n" + arg2.unseal.underlyingArgument.showExtractors) } } diff --git a/tests/run/tasty-argument-tree-1/quoted_1.scala b/tests/run/tasty-argument-tree-1/quoted_1.scala index 1299cca529b0..bd3326147e58 100644 --- a/tests/run/tasty-argument-tree-1/quoted_1.scala +++ b/tests/run/tasty-argument-tree-1/quoted_1.scala @@ -12,8 +12,8 @@ object Macros { val tree = x.unseal '{ println() - println("tree: " + ${tree.show}) - println("tree deref. vals: " + ${tree.underlying.show}) + println("tree: " + ${tree.showExtractors}) + println("tree deref. vals: " + ${tree.underlying.showExtractors}) } } } diff --git a/tests/run/tasty-definitions-1/quoted_1.scala b/tests/run/tasty-definitions-1/quoted_1.scala index 12f409d12c40..44dba48ec467 100644 --- a/tests/run/tasty-definitions-1/quoted_1.scala +++ b/tests/run/tasty-definitions-1/quoted_1.scala @@ -77,21 +77,21 @@ object Macros { printout(definitions.ScalaPrimitiveValueClasses.map(_.name).toString) printout(definitions.ScalaNumericValueClasses.map(_.name).toString) - printout(definitions.UnitType.show) - printout(definitions.ByteType.show) - printout(definitions.CharType.show) - printout(definitions.IntType.show) - printout(definitions.LongType.show) - printout(definitions.FloatType.show) - printout(definitions.DoubleType.show) - printout(definitions.BooleanType.show) - printout(definitions.AnyType.show) - printout(definitions.AnyValType.show) - printout(definitions.AnyRefType.show) - printout(definitions.ObjectType.show) - printout(definitions.NothingType.show) - printout(definitions.NullType.show) - printout(definitions.StringType.show) + printout(definitions.UnitType.showExtractors) + printout(definitions.ByteType.showExtractors) + printout(definitions.CharType.showExtractors) + printout(definitions.IntType.showExtractors) + printout(definitions.LongType.showExtractors) + printout(definitions.FloatType.showExtractors) + printout(definitions.DoubleType.showExtractors) + printout(definitions.BooleanType.showExtractors) + printout(definitions.AnyType.showExtractors) + printout(definitions.AnyValType.showExtractors) + printout(definitions.AnyRefType.showExtractors) + printout(definitions.ObjectType.showExtractors) + printout(definitions.NothingType.showExtractors) + printout(definitions.NullType.showExtractors) + printout(definitions.StringType.showExtractors) '{println(${buff.result().mkString("\n")})} diff --git a/tests/run/tasty-extractors-1/quoted_1.scala b/tests/run/tasty-extractors-1/quoted_1.scala index d6ac18a4dac3..01f821d86b20 100644 --- a/tests/run/tasty-extractors-1/quoted_1.scala +++ b/tests/run/tasty-extractors-1/quoted_1.scala @@ -12,8 +12,8 @@ object Macros { import reflect._ val tree = x.unseal - val treeStr = tree.show - val treeTpeStr = tree.tpe.show + val treeStr = tree.showExtractors + val treeTpeStr = tree.tpe.showExtractors '{ println(${treeStr}) diff --git a/tests/run/tasty-extractors-2/quoted_1.scala b/tests/run/tasty-extractors-2/quoted_1.scala index 89147b285485..0743500f210c 100644 --- a/tests/run/tasty-extractors-2/quoted_1.scala +++ b/tests/run/tasty-extractors-2/quoted_1.scala @@ -13,8 +13,8 @@ object Macros { val tree = x.unseal - val treeStr = tree.show - val treeTpeStr = tree.tpe.show + val treeStr = tree.showExtractors + val treeTpeStr = tree.tpe.showExtractors '{ println(${treeStr}) diff --git a/tests/run/tasty-extractors-3/quoted_1.scala b/tests/run/tasty-extractors-3/quoted_1.scala index 869df0921690..b46d59f8744d 100644 --- a/tests/run/tasty-extractors-3/quoted_1.scala +++ b/tests/run/tasty-extractors-3/quoted_1.scala @@ -15,11 +15,11 @@ object Macros { val traverser = new TreeTraverser { override def traverseTree(tree: Tree)(implicit ctx: Context): Unit = tree match { case IsTypeBoundsTree(tree) => - buff.append(tree.tpe.show) + buff.append(tree.tpe.showExtractors) buff.append("\n\n") traverseTreeChildren(tree) case IsTypeTree(tree) => - buff.append(tree.tpe.show) + buff.append(tree.tpe.showExtractors) buff.append("\n\n") traverseTreeChildren(tree) case _ => diff --git a/tests/run/tasty-extractors-types/quoted_1.scala b/tests/run/tasty-extractors-types/quoted_1.scala index e1525d5e7753..39f065026123 100644 --- a/tests/run/tasty-extractors-types/quoted_1.scala +++ b/tests/run/tasty-extractors-types/quoted_1.scala @@ -12,8 +12,8 @@ object Macros { val tree = x.unseal '{ - println(${tree.show}) - println(${tree.tpe.show}) + println(${tree.showExtractors}) + println(${tree.tpe.showExtractors}) println() } } diff --git a/tests/run/xml-interpolation-1/XmlQuote_1.scala b/tests/run/xml-interpolation-1/XmlQuote_1.scala index 65fc0a706d43..38506222fb0c 100644 --- a/tests/run/xml-interpolation-1/XmlQuote_1.scala +++ b/tests/run/xml-interpolation-1/XmlQuote_1.scala @@ -22,7 +22,7 @@ object XmlQuote { // for debugging purpose def pp(tree: Tree): Unit = { - println(tree.show) + println(tree.showExtractors) println(tree.showCode) } @@ -53,7 +53,7 @@ object XmlQuote { values.forall(isStringConstant) => values.collect { case Literal(Constant.String(value)) => value } case tree => - abort(s"String literal expected, but ${tree.show} found") + abort(s"String literal expected, but ${tree.showExtractors} found") } // [a0, ...]: Any* diff --git a/tests/run/xml-interpolation-2/XmlQuote_1.scala b/tests/run/xml-interpolation-2/XmlQuote_1.scala index a564e7d882a7..02c44f086a8e 100644 --- a/tests/run/xml-interpolation-2/XmlQuote_1.scala +++ b/tests/run/xml-interpolation-2/XmlQuote_1.scala @@ -21,7 +21,7 @@ object XmlQuote { // for debugging purpose def pp(tree: Tree): Unit = { - println(tree.show) + println(tree.showExtractors) println(tree.showCode) }