New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[analysis] Improve keyword reg support for re-frame #1266
Conversation
@borkdude not sure we need to add the |
src/clj_kondo/impl/hooks.clj
Outdated
@@ -19,9 +19,9 @@ | |||
|
|||
(defn reg-keyword! | |||
([k] | |||
(reg-keyword! k true)) | |||
(reg-keyword! k nil)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it didn't seem right to register the keyword as a :reg true
if user just reg-keyword! :kw
without the intention of register that keyword as a definition, for those cases the 2 arity seems the correct approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, so this arity can be removed? Would it be useful for LSP to also have ref-keyword
so you can find if re-frame.core/subscribe
or re-frame.core/dispatch
(specifically one of those) uses the keyword? Or is this covered by find-references
well enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's not necessary, the find references seems enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, let's remove it then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@borkdude not sure we should remove the 1 arity, imagine user wants to reg a keyword but not necessarily it's a keyword that is a definition, so just (reg-keyword! :my-key)
looks valid, otherwise user would always register the keyword with the :def
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would a user ever want to "register" a keyword without any context? And didn't you rename that key to :reg
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ops, yeah, :reg
😅.
You are right, if user don't register it, clj-kondo will reg as a normal keyword anyway.
I'll remove it so
Tested with clojure-lsp and with this we have |
@ericdallo Looks awesome! Could you add one more test for the |
Done @borkdude! |
Fixes #1159
:def
->:reg
re-frame.core
functions that register a keyword as definition.