Skip to content

Commit 26ff3d3

Browse files
committed
Add prefixes to printed extractors
1 parent 7e5070e commit 26ff3d3

7 files changed

+262
-262
lines changed

library/src/scala/tasty/util/TastyPrinter.scala

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -28,43 +28,43 @@ class TastyPrinter[T <: Tasty with Singleton](val tasty: T) {
2828

2929
def visitTree(x: Tree): Buffer = x match {
3030
case Term.Ident(name) =>
31-
this += "Ident(\"" += name += "\")"
31+
this += "Term.Ident(\"" += name += "\")"
3232
case Term.Select(qualifier, name, signature) =>
33-
this += "Select(" += qualifier += ", \"" += name += "\", " += signature += ")"
33+
this += "Term.Select(" += qualifier += ", \"" += name += "\", " += signature += ")"
3434
case Term.This(qual) =>
35-
this += "This(" += qual += ")"
35+
this += "Term.This(" += qual += ")"
3636
case Term.Super(qual, mix) =>
37-
this += "TypeApply(" += qual += ", " += mix += ")"
37+
this += "Term.TypeApply(" += qual += ", " += mix += ")"
3838
case Term.Apply(fun, args) =>
39-
this += "Apply(" += fun += ", " ++= args += ")"
39+
this += "Term.Apply(" += fun += ", " ++= args += ")"
4040
case Term.TypeApply(fun, args) =>
41-
this += "TypeApply(" += fun += ", " ++= args += ")"
41+
this += "Term.TypeApply(" += fun += ", " ++= args += ")"
4242
case Term.Literal(const) =>
43-
this += "Literal(" += const += ")"
43+
this += "Term.Literal(" += const += ")"
4444
case Term.New(tpt) =>
45-
this += "New(" += tpt += ")"
45+
this += "Term.New(" += tpt += ")"
4646
case Term.Typed(expr, tpt) =>
47-
this += "Typed(" += expr += ", " += tpt += ")"
47+
this += "Term.Typed(" += expr += ", " += tpt += ")"
4848
case Term.NamedArg(name, arg) =>
49-
this += "NamedArg(\"" += name += "\", " += arg += ")"
49+
this += "Term.NamedArg(\"" += name += "\", " += arg += ")"
5050
case Term.Assign(lhs, rhs) =>
51-
this += "Assign(" += lhs += ", " += rhs += ")"
51+
this += "Term.Assign(" += lhs += ", " += rhs += ")"
5252
case Term.Block(stats, expr) =>
53-
this += "Block(" ++= stats += ", " += expr += ")"
53+
this += "Term.Block(" ++= stats += ", " += expr += ")"
5454
case Term.If(cond, thenp, elsep) =>
55-
this += "If(" += cond += ", " += thenp += ", " += elsep += ")"
55+
this += "Term.If(" += cond += ", " += thenp += ", " += elsep += ")"
5656
case Term.Lambda(meth, tpt) =>
57-
this += "Lambda(" += meth += ", " += tpt += ")"
57+
this += "Term.Lambda(" += meth += ", " += tpt += ")"
5858
case Term.Match(selector, cases) =>
59-
this += "Match(" += selector += ", " ++= cases += ")"
59+
this += "Term.Match(" += selector += ", " ++= cases += ")"
6060
case Term.Return(expr) =>
61-
this += "Return(" += expr += ")"
61+
this += "Term.Return(" += expr += ")"
6262
case Term.Try(block, handlers, finalizer) =>
63-
this += "Try(" += block += ", " ++= handlers += ", " += finalizer += ")"
63+
this += "Term.Try(" += block += ", " ++= handlers += ", " += finalizer += ")"
6464
case Term.Repeated(elems) =>
65-
this += "Repeated(" ++= elems += ")"
65+
this += "Term.Repeated(" ++= elems += ")"
6666
case Term.Inlined(call, bindings, expansion) =>
67-
this += "Inlined(" += call += ", " ++= bindings += ", " += expansion += ")"
67+
this += "Term.Inlined(" += call += ", " ++= bindings += ", " += expansion += ")"
6868
case ValDef(name, tpt, rhs) =>
6969
this += "ValDef(\"" += name += "\", " += tpt += ", " += rhs += ")"
7070
case DefDef(name, typeParams, paramss, returnTpt, rhs) =>
@@ -88,25 +88,25 @@ class TastyPrinter[T <: Tasty with Singleton](val tasty: T) {
8888

8989
def visitTypeTree(x: TypeOrBoundsTree): Buffer = x match {
9090
case TypeTree.Synthetic() =>
91-
this += "Synthetic()"
91+
this += "TypeTree.Synthetic()"
9292
case TypeTree.TypeIdent(name) =>
93-
this += "TypeIdent(\"" += name += "\")"
93+
this += "TypeTree.TypeIdent(\"" += name += "\")"
9494
case TypeTree.TypeSelect(qualifier, name) =>
95-
this += "TypeSelect(" += qualifier += ", \"" += name += "\")"
95+
this += "TypeTree.TypeSelect(" += qualifier += ", \"" += name += "\")"
9696
case TypeTree.Singleton(ref) =>
97-
this += "Singleton(" += ref += ")"
97+
this += "TypeTree.Singleton(" += ref += ")"
9898
case TypeTree.And(left, right) =>
99-
this += "And(" += left += ", " += right += ")"
99+
this += "TypeTree.And(" += left += ", " += right += ")"
100100
case TypeTree.Or(left, right) =>
101-
this += "Or(" += left += ", " += right += ")"
101+
this += "TypeTree.Or(" += left += ", " += right += ")"
102102
case TypeTree.Refined(tpt, refinements) =>
103-
this += "Refined(" += tpt += ", " ++= refinements += ")"
103+
this += "TypeTree.Refined(" += tpt += ", " ++= refinements += ")"
104104
case TypeTree.Applied(tpt, args) =>
105-
this += "Applied(" += tpt += ", " ++= args += ")"
105+
this += "TypeTree.Applied(" += tpt += ", " ++= args += ")"
106106
case TypeTree.ByName(result) =>
107-
this += "ByName(" += result += ")"
107+
this += "TypeTree.ByName(" += result += ")"
108108
case TypeTree.Annotated(arg, annot) =>
109-
this += "Annotated(" += arg += ", " += annot += ")"
109+
this += "TypeTree.Annotated(" += arg += ", " += annot += ")"
110110
case TypeBoundsTree(lo, hi) =>
111111
this += "TypeBoundsTree(" += lo += ", " += hi += ")"
112112
}
@@ -118,34 +118,34 @@ class TastyPrinter[T <: Tasty with Singleton](val tasty: T) {
118118

119119
def visitPattern(x: Pattern): Buffer = x match {
120120
case Pattern.Value(v) =>
121-
this += "Value(" += v += ")"
121+
this += "Pattern.Value(" += v += ")"
122122
case Pattern.Bind(name, body) =>
123-
this += "Bind(\"" += name += "\", " += body += ")"
123+
this += "Pattern.Bind(\"" += name += "\", " += body += ")"
124124
case Pattern.Unapply(fun, implicits, patterns) =>
125-
this += "Unapply(" += fun += ", " ++= implicits += ", " ++= patterns += ")"
125+
this += "Pattern.Unapply(" += fun += ", " ++= implicits += ", " ++= patterns += ")"
126126
case Pattern.Alternative(patterns) =>
127-
this += "Alternative(" ++= patterns += ")"
127+
this += "Pattern.Alternative(" ++= patterns += ")"
128128
case Pattern.TypeTest(tpt) =>
129-
this += "TypeTest(" += tpt += ")"
129+
this += "Pattern.TypeTest(" += tpt += ")"
130130
}
131131

132132
def visitConstant(x: Constant): Buffer = x match {
133-
case Constant.Unit() => this += "Unit()"
134-
case Constant.Null() => this += "Null()"
135-
case Constant.Boolean(value) => this += "Boolean(" += value += ")"
136-
case Constant.Byte(value) => this += "Byte(" += value += ")"
137-
case Constant.Short(value) => this += "Short(" += value += ")"
138-
case Constant.Char(value) => this += "Char(" += value += ")"
139-
case Constant.Int(value) => this += "Int(" += value.toString += ")"
140-
case Constant.Long(value) => this += "Long(" += value += ")"
141-
case Constant.Float(value) => this += "Float(" += value += ")"
142-
case Constant.Double(value) => this += "Double(" += value += ")"
143-
case Constant.String(value) => this += "String(\"" += value += "\")"
133+
case Constant.Unit() => this += "Constant.Unit()"
134+
case Constant.Null() => this += "Constant.Null()"
135+
case Constant.Boolean(value) => this += "Constant.Boolean(" += value += ")"
136+
case Constant.Byte(value) => this += "Constant.Byte(" += value += ")"
137+
case Constant.Short(value) => this += "Constant.Short(" += value += ")"
138+
case Constant.Char(value) => this += "Constant.Char(" += value += ")"
139+
case Constant.Int(value) => this += "Constant.Int(" += value.toString += ")"
140+
case Constant.Long(value) => this += "Constant.Long(" += value += ")"
141+
case Constant.Float(value) => this += "Constant.Float(" += value += ")"
142+
case Constant.Double(value) => this += "Constant.Double(" += value += ")"
143+
case Constant.String(value) => this += "Constant.String(\"" += value += "\")"
144144
}
145145

146146
def visitType(x: TypeOrBounds): Buffer = x match {
147147
case Type.ConstantType(value) =>
148-
this += "ConstantType(" += value += ")"
148+
this += "Type.ConstantType(" += value += ")"
149149
case Type.SymRef(sym, qual) =>
150150
def visitName(sym: Definition): Buffer = sym match {
151151
case ValDef(name, _, _) => this += "ValDef(\"" += name += "\", _, _)"
@@ -155,48 +155,48 @@ class TastyPrinter[T <: Tasty with Singleton](val tasty: T) {
155155
case PackageDef(name, _) => this += "PackageDef(\"" += name += "\", _)"
156156
case _ => this += "#"
157157
}
158-
this += "SymRef("
158+
this += "Type.SymRef("
159159
visitName(sym)
160160
this += ", " += qual += ")"
161161
case Type.TermRef(name, qual) =>
162-
this += "TermRef(\"" += name += "\", " += qual += ")"
162+
this += "Type.TermRef(\"" += name += "\", " += qual += ")"
163163
case Type.TypeRef(name, qual) =>
164-
this += "TypeRef(\"" += name += "\", " += qual += ")"
164+
this += "Type.TypeRef(\"" += name += "\", " += qual += ")"
165165
case Type.Refinement(parent, name, info) =>
166-
this += "Refinement(" += parent += ", " += name += ", " += info += ")"
166+
this += "Type.Refinement(" += parent += ", " += name += ", " += info += ")"
167167
case Type.AppliedType(tycon, args) =>
168-
this += "AppliedType(" += tycon += ", " ++= args += ")"
168+
this += "Type.AppliedType(" += tycon += ", " ++= args += ")"
169169
case Type.AnnotatedType(underlying, annot) =>
170-
this += "AnnotatedType(" += underlying += ", " += annot += ")"
170+
this += "Type.AnnotatedType(" += underlying += ", " += annot += ")"
171171
case Type.AndType(left, right) =>
172-
this += "AndType(" += left += ", " += right += ")"
172+
this += "Type.AndType(" += left += ", " += right += ")"
173173
case Type.OrType(left, right) =>
174-
this += "OrType(" += left += ", " += right += ")"
174+
this += "Type.OrType(" += left += ", " += right += ")"
175175
case Type.ByNameType(underlying) =>
176-
this += "ByNameType(" += underlying += ")"
176+
this += "Type.ByNameType(" += underlying += ")"
177177
case Type.ParamRef(binder, idx) =>
178-
this += "ParamRef(" += binder+= ", " += idx += ")"
178+
this += "Type.ParamRef(" += binder+= ", " += idx += ")"
179179
case Type.ThisType(tp) =>
180-
this += "ThisType(" += tp += ")"
180+
this += "Type.ThisType(" += tp += ")"
181181
case Type.RecursiveThis(binder) =>
182-
this += "RecursiveThis(" += binder += ")"
182+
this += "Type.RecursiveThis(" += binder += ")"
183183
case Type.MethodType(argNames, argTypes, resType) =>
184-
this += "MethodType(" ++= argNames += ", " ++= argTypes += ", " += resType += ")"
184+
this += "Type.MethodType(" ++= argNames += ", " ++= argTypes += ", " += resType += ")"
185185
case Type.PolyType(argNames, argBounds, resType) =>
186-
this += "PolyType(" ++= argNames += ", " ++= argBounds += ", " += resType += ")"
186+
this += "Type.PolyType(" ++= argNames += ", " ++= argBounds += ", " += resType += ")"
187187
case Type.TypeLambda(argNames, argBounds, resType) =>
188-
this += "TypeLambda(" ++= argNames += ", " ++= argBounds += ", " += resType += ")"
188+
this += "Type.TypeLambda(" ++= argNames += ", " ++= argBounds += ", " += resType += ")"
189189
case TypeBounds(lo, hi) =>
190190
this += "TypeBounds(" += lo += ", " += hi += ")"
191191
case NoPrefix() =>
192-
this += "NoPrefix"
192+
this += "NoPrefix()"
193193
}
194194

195195
def visitModifier(x: Modifier): Buffer = x match {
196-
case Modifier.Flags(flags) => this += "Flags(" += flags.toString += ")"
197-
case Modifier.QualifiedPrivate(tp) => this += "QualifiedPrivate(" += tp += ")"
198-
case Modifier.QualifiedProtected(tp) => this += "QualifiedProtected(" += tp += ")"
199-
case Modifier.Annotation(tree) => this += "Annotation(" += tree += ")"
196+
case Modifier.Flags(flags) => this += "Modifier.Flags(" += flags.toString += ")"
197+
case Modifier.QualifiedPrivate(tp) => this += "Modifier.QualifiedPrivate(" += tp += ")"
198+
case Modifier.QualifiedProtected(tp) => this += "Modifier.QualifiedProtected(" += tp += ")"
199+
case Modifier.Annotation(tree) => this += "Modifier.Annotation(" += tree += ")"
200200
}
201201

202202
def visitId(x: Id): Buffer = {

0 commit comments

Comments
 (0)