I want to take a namespace file and rewrite symbols that point to vars that are referred from a particular namespaces to use an alias. (so replacing instances of map-vals with m/map-vals for example) I think I need a tools.analyzer ast to find the symbol/var pairs being used, but then I think I want something like rewrite-clj to emit the changes to the source code as a string. Is there a way to pair a tools.analyzer AST with the rewrite-clj AST? I vaguely remember seeing something like that.
@jjttjj You can do this using clj-kondo (although you could probably use tools analyzer) and rewrite-clj. The way to do this is use the clj-kondo analysis output and then compare it to the location of the rewrite-clj nodes. A demo of applying this is here:
https://github.com/clj-kondo/clj-kondo/tree/master/analysis#ast
That's perfect, thanks!