@@ -179,6 +179,43 @@ trait TreeOps extends Core {
179
179
def pos (implicit ctx : Context ): Position = kernel.Term_pos (self)
180
180
def underlyingArgument (implicit ctx : Context ): Term = kernel.Term_underlyingArgument (self)
181
181
def underlying (implicit ctx : Context ): Term = kernel.Term_underlying (self)
182
+
183
+ /** A unary apply node with given argument: `tree(arg)` */
184
+ def appliedTo (arg : Term )(implicit ctx : Context ): Term =
185
+ appliedToArgs(arg :: Nil )
186
+
187
+ /** An apply node with given arguments: `tree(arg, args0, ..., argsN)` */
188
+ def appliedTo (arg : Term , args : Term * )(implicit ctx : Context ): Term =
189
+ appliedToArgs(arg :: args.toList)
190
+
191
+ /** An apply node with given argument list `tree(args(0), ..., args(args.length - 1))` */
192
+ def appliedToArgs (args : List [Term ])(implicit ctx : Context ): Apply =
193
+ Apply (self, args)
194
+
195
+ /** The current tree applied to given argument lists:
196
+ * `tree (argss(0)) ... (argss(argss.length -1))`
197
+ */
198
+ def appliedToArgss (argss : List [List [Term ]])(implicit ctx : Context ): Term =
199
+ ((self : Term ) /: argss)(Apply (_, _))
200
+
201
+ /** The current tree applied to (): `tree()` */
202
+ def appliedToNone (implicit ctx : Context ): Apply = appliedToArgs(Nil )
203
+
204
+ /** The current tree applied to given type argument: `tree[targ]` */
205
+ def appliedToType (targ : Type )(implicit ctx : Context ): Term =
206
+ appliedToTypes(targ :: Nil )
207
+
208
+ /** The current tree applied to given type arguments: `tree[targ0, ..., targN]` */
209
+ def appliedToTypes (targs : List [Type ])(implicit ctx : Context ): Term =
210
+ appliedToTypeTrees(targs map (Inferred (_)))
211
+
212
+ /** The current tree applied to given type argument list: `tree[targs(0), ..., targs(targs.length - 1)]` */
213
+ def appliedToTypeTrees (targs : List [TypeTree ])(implicit ctx : Context ): Term =
214
+ if (targs.isEmpty) self else TypeApply (self, targs)
215
+
216
+ /** A select node that selects the given symbol.
217
+ */
218
+ def select (sym : Symbol )(implicit ctx : Context ): Select = Select (self, sym)
182
219
}
183
220
184
221
object IsTerm {
0 commit comments