Fork me on GitHub
#lsp
<
2024-06-05
>
Alexander Kouznetsov18:06:33

Is it possible to access lsp cache to perform programmatic updates to the codebase? Iā€™m looking into doing the following update - I want to replace all calls to a ns-a/fn-a to calls to ns-b/fn-b and modify the arguments as I do this and fix the requires. For example, in abc.clj I will change (a/fn-a arg1 arg2) to (b/fn-b arg2 {:arg1 arg1}) or something of this kind, I will also remove require for a and add a new require for b. I want to apply the same update to all 100 instances of the fn-a call. Can lsp help me with that?

Alexander Kouznetsov18:06:35

As a potential way to implement this, maybe LSP supports inlining all the function calls? So that I can implement a specific change inside fn-a and then inline all the calls to it?

ericdallo18:06:16

That's why clojure-lsp has an API, you can call it in a clojure code or call it via cli, check https://clojure-lsp.io/api/what-is-it/

šŸ™Œ 1
ericdallo18:06:08

There are some redactors in clojure-lsp.api that may help you, like clojure-lspmapi/rename! And clean-ns

šŸ™Œ 1