I have tested scalameta and it works nice for modifying the AST.
However, I came to the conclusion that I probably need type information as well. I have asked on StackOverflow: https://stackoverflow.com/questions/57132249/how-to-get-the-type-of-a-variable-with-scalameta-if-the-decltpe-is-empty
It seems that I have to compile the project first, generating a semanticdb with the type information and then I can instrument the source code but I have to use the generated semanticdb files to get the type information of the expressions.
This seems rather complicated.
Is there some easier way to get the type information while modifying the AST?
For example, would it be easier to write a compiler plugin for Scala which probably has all the information?
So far I have only found this: https://docs.scala-lang.org/overviews/plugins/index.html
It seems like the user would have to add only:
addCompilerPlugin("bla" % "myplugin" % "1.0")
and the plugin could instrument the source code during the compilation phase and would have all the type information?
However, it seems to use internal AST types of Scala instead of scalameta.
Does anyone have experience with writing compiler plugins or can recommend an easier way than generating the scalametadb files and using them while transforming the AST?