Scala-meta for instrumentation

91 Views Asked by At

I noticed that scala-meta provides transformation functions, but not functions to insert additional code (e.g., import statements, or a method call at every start of a function).

Since all structures (scala.meta.Tree and its children) are immutable, I'm not sure if it possible and how I would achieve this?

1

There are 1 best solutions below

0
On

Essentially, A new tree structure has to be built based on the original with whatever modifications are desired. Tree.transform allows just such a thing.