Finding all uses of a namespaced keyword

I’m trying to figure out how to search for all instances of a specific namespaced keyword in a Clojure codebase. Does anyone know of a tool that can help accomplish this?

The main complication is that destructuring has a few different ways of representing a namespaced keyword. Then there are also namespaced maps.

I believe that macroexpansion will have to take place and then search through the expanded code, however this likely means that it won’t be possible to find the exact location of the namespaced keyword, but just having the function where it is used would be ok.

I was just wondering whether there is an existing tool that can help with this.

You might look into GitHub - clj-commons/rewrite-clj: Rewrite Clojure code and edn

I’ve not used it yet but its on my bucket list.
It believe it will allow you to transform the ast while also tracking the original source location probably on the metadata but its been a while since I looked it over

1 Like

Pretty sure Cursive (Clojure IntelliJ plugin) does this? I use it regularly. It can certainly find usages of keywords referenced in map destructuring for example :slight_smile:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.