-
Notifications
You must be signed in to change notification settings - Fork 634
Tests for more Clojure tags #4126
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
About methodId kind, see #4126. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--sort=no | ||
--fields=+KzZ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
multimethod.test input.clj /^(ns multimethod.test)$/;" kind:namespace | ||
test input.clj /^(defmulti test$/;" kind:multi scope:namespace:multimethod.test | ||
documented-multimethod input.clj /^(defmulti documented-multimethod "Documentation"$/;" kind:multi scope:namespace:multimethod.test | ||
test input.clj /^(defmethod test nil$/;" kind:method scope:namespace:multimethod.test | ||
test input.clj /^(defmethod test :test$/;" kind:method scope:namespace:multimethod.test | ||
test input.clj /^(defmethod test :test2 named-method$/;" kind:method scope:namespace:multimethod.test | ||
named-method input.clj /^(defmethod test :test2 named-method$/;" kind:methodId method:test scope:namespace:multimethod.test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
(ns multimethod.test) | ||
|
||
(defmulti test | ||
(fn [type] type)) | ||
|
||
(defmulti documented-multimethod "Documentation" | ||
(fn [type] type)) | ||
|
||
(defmethod test nil | ||
[& _] | ||
nil) | ||
|
||
(defmethod test :test | ||
[& _] | ||
nil) | ||
|
||
(defmethod test :test2 named-method | ||
[& _] | ||
nil) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--sort=no | ||
--fields=+KzZ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
vars.test input.clj /^(ns vars.test)$/;" kind:namespace | ||
var input.clj /^(def var 'var)$/;" kind:variable namespace:vars.test | ||
doc-var input.clj /^(def doc-var "Documentation" 'var)$/;" kind:variable scope:namespace:vars.test | ||
dynamic-var input.clj /^(def dynamic-var ^:dynamic 'var)$/;" kind:variable scope:namespace:vars.test | ||
const-var input.clj /^(def const-var ^:const 'var)$/;" kind:variable scope:namespace:vars.test | ||
once-var input.clj /^(defonce once-var 'evaluated-once)$/;" kind:variable scope:namespace:vars.test | ||
fn-var input.clj /^(def fn-var (fn [] true))$/;" kind:function scope:namespace:vars.test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
(ns vars.test) | ||
|
||
(def var 'var) | ||
|
||
(def doc-var "Documentation" 'var) | ||
|
||
(def dynamic-var ^:dynamic 'var) | ||
|
||
(def const-var ^:const 'var) | ||
|
||
(defonce once-var 'evaluated-once) | ||
|
||
(def fn-var (fn [] true)) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you explain this line?
I wonder why
named-method
should be extracted because my knowledge of Clojure is limited.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's a method-specific name that's added to multimethod function name. See https://clojuredocs.org/clojure.core/defmethod#example-542692c7c026201cdc3269cd
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.
I need help understanding.
Can named-method be used with a function?
I guess, with the name, a user can call the method by passing multi-method-dispatching. If my guessing is correct,I think 'named-method' should be tagged as a function, not a method.
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.
No, it doesn't work as a self-sufficient function. It's merely a piece of metadata identifying the method. It's only useful in debugging and (given ctags support) in location search.
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.
I see. Thank you. We should introduce a new kind for such a language object. What do Clojure hackers call it? I think of
method-identifier/i
ormethod-id/i
.The ideal tags for
named-method
looks like:Anyway, the current Clojure parser cannot extract caddr.
So, to satisfy these new test cases, we must rewrite the parser.
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.
Sorry for disappearing 😔 Why not named method? But yes,
method-id(endifier)
is fine by me too!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.
If
named-method
is tagged as a method, a client tool like Vim may show it as a candidate in input completion.However, it is not callable, as you wrote. So,
named-method
should not be shown on the candidate list. Ifnamed-method
is tagged as a method-id, Vim may not show as far as Vim shows onlymethod
kind tags.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, all fair!