@@ -12,11 +12,11 @@ abstract class TreeAccumulator[X, T <: Tasty with Singleton](val tasty: T) {
12
12
def foldPattern (x : X , tree : Pattern )(implicit ctx : Context ): X
13
13
def foldParent (x : X , tree : Parent )(implicit ctx : Context ): X
14
14
15
- def foldTree (x : X , trees : Traversable [Tree ])(implicit ctx : Context ): X = (x /: trees)(foldTree)
16
- def foldTypeTree (x : X , trees : Traversable [MaybeTypeTree ])(implicit ctx : Context ): X = (x /: trees)(foldTypeTree)
17
- def foldCaseDef (x : X , trees : Traversable [CaseDef ])(implicit ctx : Context ): X = (x /: trees)(foldCaseDef)
18
- def foldPattern (x : X , trees : Traversable [Pattern ])(implicit ctx : Context ): X = (x /: trees)(foldPattern)
19
- def foldParent (x : X , trees : Traversable [Parent ])(implicit ctx : Context ): X = (x /: trees)(foldParent)
15
+ def foldTrees (x : X , trees : Iterable [Tree ])(implicit ctx : Context ): X = (x /: trees)(foldTree)
16
+ def foldTypeTrees (x : X , trees : Iterable [MaybeTypeTree ])(implicit ctx : Context ): X = (x /: trees)(foldTypeTree)
17
+ def foldCaseDefs (x : X , trees : Iterable [CaseDef ])(implicit ctx : Context ): X = (x /: trees)(foldCaseDef)
18
+ def foldPatterns (x : X , trees : Iterable [Pattern ])(implicit ctx : Context ): X = (x /: trees)(foldPattern)
19
+ def foldParents (x : X , trees : Iterable [Parent ])(implicit ctx : Context ): X = (x /: trees)(foldParent)
20
20
21
21
def foldOverTree (x : X , tree : Tree )(implicit ctx : Context ): X = {
22
22
def localCtx (definition : Definition ): Context = definition.localContext
@@ -30,9 +30,9 @@ abstract class TreeAccumulator[X, T <: Tasty with Singleton](val tasty: T) {
30
30
case Super (qual, _) =>
31
31
foldTree(x, qual)
32
32
case Apply (fun, args) =>
33
- foldTree (foldTree(x, fun), args)
33
+ foldTrees (foldTree(x, fun), args)
34
34
case TypeApply (fun, args) =>
35
- foldTypeTree (foldTree(x, fun), args)
35
+ foldTypeTrees (foldTree(x, fun), args)
36
36
case Literal (const) =>
37
37
x
38
38
case New (tpt) =>
@@ -44,39 +44,39 @@ abstract class TreeAccumulator[X, T <: Tasty with Singleton](val tasty: T) {
44
44
case Assign (lhs, rhs) =>
45
45
foldTree(foldTree(x, lhs), rhs)
46
46
case Block (stats, expr) =>
47
- foldTree(foldTree (x, stats), expr)
47
+ foldTree(foldTrees (x, stats), expr)
48
48
case If (cond, thenp, elsep) =>
49
49
foldTree(foldTree(foldTree(x, cond), thenp), elsep)
50
50
case Lambda (meth, tpt) =>
51
51
val a = foldTree(x, meth)
52
52
tpt.fold(a)(b => foldTypeTree(a, b))
53
53
case Match (selector, cases) =>
54
- foldCaseDef (foldTree(x, selector), cases)
54
+ foldCaseDefs (foldTree(x, selector), cases)
55
55
case Return (expr) =>
56
56
foldTree(x, expr)
57
57
case Try (block, handler, finalizer) =>
58
- foldTree(foldCaseDef (foldTree(x, block), handler), finalizer)
58
+ foldTrees(foldCaseDefs (foldTree(x, block), handler), finalizer)
59
59
case Repeated (elems) =>
60
- foldTree (x, elems)
60
+ foldTrees (x, elems)
61
61
case Inlined (call, bindings, expansion) =>
62
- foldTree(foldTree (x, bindings), expansion)
62
+ foldTree(foldTrees (x, bindings), expansion)
63
63
64
64
case vdef @ ValDef (_, tpt, rhs) =>
65
65
implicit val ctx = localCtx(vdef)
66
- foldTree (foldTypeTree(x, tpt), rhs)
66
+ foldTrees (foldTypeTree(x, tpt), rhs)
67
67
case ddef @ DefDef (_, tparams, vparamss, tpt, rhs) =>
68
68
implicit val ctx = localCtx(ddef)
69
- foldTree (foldTypeTree((foldTree (x, tparams) /: vparamss)(foldTree ), tpt), rhs)
69
+ foldTrees (foldTypeTree((foldTrees (x, tparams) /: vparamss)(foldTrees ), tpt), rhs)
70
70
case tdef @ TypeDef (_, rhs) =>
71
71
implicit val ctx = localCtx(tdef)
72
72
foldTypeTree(x, rhs)
73
73
case cdef @ ClassDef (_, constr, parents, self, body) =>
74
74
implicit val ctx = localCtx(cdef)
75
- foldTree(foldTree(foldParent (foldTree(x, constr), parents), self), body)
75
+ foldTrees(foldTrees(foldParents (foldTree(x, constr), parents), self), body)
76
76
case Import (expr, selectors) =>
77
77
foldTree(x, expr)
78
78
case clause @ PackageClause (pid, stats) =>
79
- foldTree (foldTree(x, pid), stats)(localCtx(clause.definition))
79
+ foldTrees (foldTree(x, pid), stats)(localCtx(clause.definition))
80
80
}
81
81
}
82
82
@@ -87,22 +87,22 @@ abstract class TreeAccumulator[X, T <: Tasty with Singleton](val tasty: T) {
87
87
case Singleton (ref) => foldTree(x, ref)
88
88
case And (left, right) => foldTypeTree(foldTypeTree(x, left), right)
89
89
case Or (left, right) => foldTypeTree(foldTypeTree(x, left), right)
90
- case Refined (tpt, refinements) => foldTree (foldTypeTree(x, tpt), refinements)
91
- case Applied (tpt, args) => foldTypeTree (foldTypeTree(x, tpt), args)
90
+ case Refined (tpt, refinements) => foldTrees (foldTypeTree(x, tpt), refinements)
91
+ case Applied (tpt, args) => foldTypeTrees (foldTypeTree(x, tpt), args)
92
92
case ByName (result) => foldTypeTree(x, result)
93
93
case Annotated (arg, annot) => foldTree(foldTypeTree(x, arg), annot)
94
94
case TypeBoundsTree (lo, hi) => foldTypeTree(foldTypeTree(x, lo), hi)
95
95
}
96
96
97
97
def foldOverCaseDef (x : X , tree : CaseDef )(implicit ctx : Context ): X = tree match {
98
- case CaseDef (pat, guard, body) => foldTree(foldTree (foldPattern(x, pat), guard), body)
98
+ case CaseDef (pat, guard, body) => foldTree(foldTrees (foldPattern(x, pat), guard), body)
99
99
}
100
100
101
101
def foldOverPattern (x : X , tree : Pattern )(implicit ctx : Context ): X = tree match {
102
102
case Value (v) => foldTree(x, v)
103
103
case Bind (_, body) => foldPattern(x, body)
104
- case Unapply (fun, implicits, patterns) => foldPattern(foldTree (foldTree(x, fun), implicits), patterns)
105
- case Alternative (patterns) => foldPattern (x, patterns)
104
+ case Unapply (fun, implicits, patterns) => foldPatterns(foldTrees (foldTree(x, fun), implicits), patterns)
105
+ case Alternative (patterns) => foldPatterns (x, patterns)
106
106
case TypeTest (tpt) => foldTypeTree(x, tpt)
107
107
}
108
108
0 commit comments