Parse Elixir Module AST to replace functions and replace the original source file?

TLDR: you can do this, but you can’t preserve code formatting, comments and other stuff which is not part of AST. I’ve been investigating a similar case here: Mix deps.add functionality