search term:

treehugger.scala pamflet

treehugger is a library to write Scala source code programmatically. It’s also an implementation of Scala AST based on Reflection API, now available from github eed3si9n/treehugger.

Edit: I’ve expanded this into a complete guide using awesome n8han/pamflet.