rewrite-clj

2023-04-18T13:17:37.608089Z

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.

borkdude 2023-04-18T13:29:52.608779Z

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

2023-04-18T13:41:27.929819Z

That's perfect, thanks!