clojure-lsp icon indicating copy to clipboard operation
clojure-lsp copied to clipboard

Rename namespace alias with API / CLI

Open witek opened this issue 11 months ago • 3 comments

Is your feature request related to a problem? Please describe.

In the Editor integration I can point to a namespace alias and then rename it. But this feature is not exposed to the public API.

Describe the solution you'd like

Option A:

(clojure-lsp.api/rename-ns-alias!
 {:target-namespace 'clojure.string
  :alias 'str })

Running this on the project, would unify the alias to clojure.string in all files.

Option B:

(clojure-lsp.api/rename-ns-alias!
 {:from 'clojure-string
  :to 'str})

This would only match an existing alias clojure-string and rename it, independent of the target namespace it points to.

witek avatar Mar 15 '24 16:03 witek

Would be nice if we could use the same existing rename! function supporting the alias

ericdallo avatar Mar 15 '24 16:03 ericdallo

Would be nice if we could use the same existing rename! function supporting the alias

Du you have a specific reason for this? The current rename! function expects symbols in :from and :to, while renaming an alias needs different types of arguments. Also there could be an alias with the same name as a var in a namespace. Then it would be not clear, which one is targeted.

My first guess is, that two simpler functions are easier to understand then one which complicates the two things.

witek avatar Mar 19 '24 11:03 witek

yeah, would complicate a little bit the internal api, but I agree it's easier, I think a separated one is a good way.

ericdallo avatar Mar 23 '24 13:03 ericdallo