-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
BuildUtils.scala
294 lines (213 loc) · 9.68 KB
/
BuildUtils.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
package scala
package reflect
package api
/**
* This is an internal implementation class.
* @groupname TreeBuilders Tree Building
*/
private[reflect] trait BuildUtils { self: Universe =>
/** @group TreeBuilders */
val build: BuildApi
// this API abstracts away the functionality necessary for reification
// it's too gimmicky and unstructured to be exposed directly in the universe
// but we need it in a publicly available place for reification to work
/** @group TreeBuilders */
abstract class BuildApi {
/** Selects type symbol with given simple name `name` from the defined members of `owner`.
*/
def selectType(owner: Symbol, name: String): TypeSymbol
/** Selects term symbol with given name and type from the defined members of prefix type
*/
def selectTerm(owner: Symbol, name: String): TermSymbol
/** Selects overloaded method symbol with given name and index
*/
def selectOverloadedMethod(owner: Symbol, name: String, index: Int): MethodSymbol
/** A fresh symbol with given name `name`, position `pos` and flags `flags` that has
* the current symbol as its owner.
*/
def newNestedSymbol(owner: Symbol, name: Name, pos: Position, flags: FlagSet, isClass: Boolean): Symbol
/** Create a fresh free term symbol.
* @param name the name of the free variable
* @param value the value of the free variable at runtime
* @param flags (optional) flags of the free variable
* @param origin debug information that tells where this symbol comes from
*/
def newFreeTerm(name: String, value: => Any, flags: FlagSet = NoFlags, origin: String = null): FreeTermSymbol
/** Create a fresh free type symbol.
* @param name the name of the free variable
* @param flags (optional) flags of the free variable
* @param origin debug information that tells where this symbol comes from
*/
def newFreeType(name: String, flags: FlagSet = NoFlags, origin: String = null): FreeTypeSymbol
/** Set symbol's type signature to given type.
* @return the symbol itself
*/
def setTypeSignature[S <: Symbol](sym: S, tpe: Type): S
/** Set symbol's annotations to given annotations `annots`.
*/
def setAnnotations[S <: Symbol](sym: S, annots: List[Annotation]): S
def This(sym: Symbol): Tree
def Select(qualifier: Tree, sym: Symbol): Select
def Ident(sym: Symbol): Ident
def TypeTree(tp: Type): TypeTree
def thisPrefix(sym: Symbol): Type
def setType[T <: Tree](tree: T, tpe: Type): T
def setSymbol[T <: Tree](tree: T, sym: Symbol): T
def toStats(tree: Tree): List[Tree]
def mkAnnotation(tree: Tree): Tree
def mkAnnotation(trees: List[Tree]): List[Tree]
def mkRefineStat(stat: Tree): Tree
def mkRefineStat(stats: List[Tree]): List[Tree]
def mkPackageStat(stat: Tree): Tree
def mkPackageStat(stats: List[Tree]): List[Tree]
def mkEarlyDef(defn: Tree): Tree
def mkEarlyDef(defns: List[Tree]): List[Tree]
def RefTree(qual: Tree, sym: Symbol): Tree
def freshTermName(prefix: String): TermName
def freshTypeName(prefix: String): TypeName
val ImplicitParams: ImplicitParamsExtractor
trait ImplicitParamsExtractor {
def apply(paramss: List[List[ValDef]], implparams: List[ValDef]): List[List[ValDef]]
def unapply(vparamss: List[List[ValDef]]): Some[(List[List[ValDef]], List[ValDef])]
}
val ScalaDot: ScalaDotExtractor
trait ScalaDotExtractor {
def apply(name: Name): Tree
def unapply(tree: Tree): Option[Name]
}
val FlagsRepr: FlagsReprExtractor
trait FlagsReprExtractor {
def apply(value: Long): FlagSet
def unapply(flags: Long): Some[Long]
}
val SyntacticTypeApplied: SyntacticTypeAppliedExtractor
trait SyntacticTypeAppliedExtractor {
def apply(tree: Tree, targs: List[Tree]): Tree
def unapply(tree: Tree): Some[(Tree, List[Tree])]
}
val SyntacticApplied: SyntacticAppliedExtractor
trait SyntacticAppliedExtractor {
def apply(tree: Tree, argss: List[List[Tree]]): Tree
def unapply(tree: Tree): Some[(Tree, List[List[Tree]])]
}
val SyntacticClassDef: SyntacticClassDefExtractor
trait SyntacticClassDefExtractor {
def apply(mods: Modifiers, name: TypeName, tparams: List[Tree],
constrMods: Modifiers, vparamss: List[List[Tree]],
earlyDefs: List[Tree], parents: List[Tree], selfType: Tree, body: List[Tree]): ClassDef
def unapply(tree: Tree): Option[(Modifiers, TypeName, List[TypeDef], Modifiers, List[List[ValDef]],
List[Tree], List[Tree], ValDef, List[Tree])]
}
val SyntacticTraitDef: SyntacticTraitDefExtractor
trait SyntacticTraitDefExtractor {
def apply(mods: Modifiers, name: TypeName, tparams: List[Tree],
earlyDefs: List[Tree], parents: List[Tree], selfType: Tree, body: List[Tree]): ClassDef
def unapply(tree: Tree): Option[(Modifiers, TypeName, List[TypeDef],
List[Tree], List[Tree], ValDef, List[Tree])]
}
val SyntacticObjectDef: SyntacticObjectDefExtractor
trait SyntacticObjectDefExtractor {
def apply(mods: Modifiers, name: TermName, earlyDefs: List[Tree],
parents: List[Tree], selfType: Tree, body: List[Tree]): ModuleDef
def unapply(tree: Tree): Option[(Modifiers, TermName, List[Tree], List[Tree], ValDef, List[Tree])]
}
val SyntacticPackageObjectDef: SyntacticPackageObjectDefExtractor
trait SyntacticPackageObjectDefExtractor {
def apply(name: TermName, earlyDefs: List[Tree],
parents: List[Tree], selfType: Tree, body: List[Tree]): PackageDef
def unapply(tree: Tree): Option[(TermName, List[Tree], List[Tree], ValDef, List[Tree])]
}
val SyntacticTuple: SyntacticTupleExtractor
val SyntacticTupleType: SyntacticTupleExtractor
trait SyntacticTupleExtractor {
def apply(args: List[Tree]): Tree
def unapply(tree: Tree): Option[List[Tree]]
}
val SyntacticBlock: SyntacticBlockExtractor
trait SyntacticBlockExtractor {
def apply(stats: List[Tree]): Tree
def unapply(tree: Tree): Option[List[Tree]]
}
val SyntacticNew: SyntacticNewExtractor
trait SyntacticNewExtractor {
def apply(earlyDefs: List[Tree], parents: List[Tree], selfType: Tree, body: List[Tree]): Tree
def unapply(tree: Tree): Option[(List[Tree], List[Tree], ValDef, List[Tree])]
}
val SyntacticFunctionType: SyntacticFunctionTypeExtractor
trait SyntacticFunctionTypeExtractor {
def apply(argtpes: List[Tree], restpe: Tree): Tree
def unapply(tree: Tree): Option[(List[Tree], Tree)]
}
val SyntacticFunction: SyntacticFunctionExtractor
trait SyntacticFunctionExtractor {
def apply(params: List[Tree], body: Tree): Tree
def unapply(tree: Tree): Option[(List[ValDef], Tree)]
}
val SyntacticDefDef: SyntacticDefDefExtractor
trait SyntacticDefDefExtractor {
def apply(mods: Modifiers, name: TermName, tparams: List[Tree],
vparamss: List[List[Tree]], tpt: Tree, rhs: Tree): DefDef
def unapply(tree: Tree): Option[(Modifiers, TermName, List[TypeDef], List[List[ValDef]], Tree, Tree)]
}
val SyntacticValDef: SyntacticValDefExtractor
val SyntacticVarDef: SyntacticValDefExtractor
trait SyntacticValDefExtractor {
def apply(mods: Modifiers, name: TermName, tpt: Tree, rhs: Tree): ValDef
def unapply(tree: Tree): Option[(Modifiers, TermName, Tree, Tree)]
}
val SyntacticAssign: SyntacticAssignExtractor
trait SyntacticAssignExtractor {
def apply(lhs: Tree, rhs: Tree): Tree
def unapply(tree: Tree): Option[(Tree, Tree)]
}
val SyntacticValFrom: SyntacticValFromExtractor
trait SyntacticValFromExtractor {
def apply(pat: Tree, rhs: Tree): Tree
def unapply(tree: Tree): Option[(Tree, Tree)]
}
val SyntacticValEq: SyntacticValEqExtractor
trait SyntacticValEqExtractor {
def apply(pat: Tree, rhs: Tree): Tree
def unapply(tree: Tree): Option[(Tree, Tree)]
}
val SyntacticFilter: SyntacticFilterExtractor
trait SyntacticFilterExtractor {
def apply(test: Tree): Tree
def unapply(tree: Tree): Option[(Tree)]
}
val SyntacticEmptyTypeTree: SyntacticEmptyTypeTreeExtractor
trait SyntacticEmptyTypeTreeExtractor {
def apply(): TypeTree
def unapply(tt: TypeTree): Boolean
}
val SyntacticFor: SyntacticForExtractor
val SyntacticForYield: SyntacticForExtractor
trait SyntacticForExtractor {
def apply(enums: List[Tree], body: Tree): Tree
def unapply(tree: Tree): Option[(List[Tree], Tree)]
}
def UnliftListElementwise[T](unliftable: Unliftable[T]): UnliftListElementwise[T]
trait UnliftListElementwise[T] {
def unapply(lst: List[Tree]): Option[List[T]]
}
def UnliftListOfListsElementwise[T](unliftable: Unliftable[T]): UnliftListOfListsElementwise[T]
trait UnliftListOfListsElementwise[T] {
def unapply(lst: List[List[Tree]]): Option[List[List[T]]]
}
val SyntacticMatch: SyntacticMatchExtractor
trait SyntacticMatchExtractor {
def apply(selector: Tree, cases: List[Tree]): Match
def unapply(tree: Match): Option[(Tree, List[CaseDef])]
}
val SyntacticTry: SyntacticTryExtractor
trait SyntacticTryExtractor {
def apply(block: Tree, catches: List[Tree], finalizer: Tree): Try
def unapply(tree: Try): Option[(Tree, List[CaseDef], Tree)]
}
val SyntacticIdent: SyntacticIdentExtractor
trait SyntacticIdentExtractor {
def apply(name: Name, isBackquoted: Boolean = false): Ident
def unapply(tree: Ident): Option[(Name, Boolean)]
}
}
}