And I’m looking for an automated way to do a search and replace into something like:
alias MyApp.Cat
alias MyApp.Dog
alias MyApp.Parrot
I suspect this might be doable with regex but I have very little skills for that. Any chance someone here has that sitting around in a notebook somewhere or other suggestion?
PS: As to why we want to do this, it is to improve the grep-ability of the source. We want to have confidence when we search for MyApp.Dog we find those module references.
That kind of transformation is safer to do on AST (versus regexing code). The formatter provides some inspiration:
In between calls to Code.string_to_quoted_with_comments! and Code.Formatter.to_algebra, you could find alias nodes in the AST and transform them into the desired shape.