Fork me on GitHub
#rewrite-clj
<
2023-04-18
>
jjttjj13:04:37

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.

borkdude13:04:52

@U064UGEUQ 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:

jjttjj13:04:27

That's perfect, thanks!