rewrite-clj

2022-09-16T23:52:16.293369Z

hi everybody! I'm trying to use rewrite-clj to rewrite my lib (ns ...) forms in a build step before creating my jar. It was pretty easy until I found (ns ...) forms with conditionals, which are parsed as (read-string "..."). What is the best way of renaming namespaces in :requires and :imports that also works with conditionals? The use case is that I need to duplicate namespaces to enable a debugger I'm writing to be able to instrument itself.

lread 2022-09-16T23:53:56.221109Z

Welcome @jpmonettas!

2022-09-16T23:54:13.449869Z

thanks!

lread 2022-09-16T23:56:27.120039Z

https://github.com/benedekfazekas/mranderson does this kind of thing but for different reasons. It uses rewrite-clj to move namespaces. Can’t remember if it deals with reader conditionals.

2022-09-16T23:57:44.211569Z

yeah I know about MrAnderson but I don't think it works for my case. But now you mention it I could take a look and try to see if I can steal some ideas from it in case it works with conditionals

lread 2022-09-16T23:59:15.034049Z

But… clj-kondo also uses a version of rewrite-clj internally https://github.com/clj-kondo/clj-kondo/tree/master/analysis. I’ve been thinking of using it for MrAnderson to quickly local namespaces and their uses. The thing I’m not sure about yet is the import references.