-
Notifications
You must be signed in to change notification settings - Fork 628
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
Tests for more Clojure tags #4126
Open
aartaka
wants to merge
2
commits into
universal-ctags:master
Choose a base branch
from
aartaka:more-clojure-tags
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 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,6 @@ | ||
documented-multimethod input.clj /^(defmulti documented-multimethod "Documentation"$/;" M multimethod.test | ||
named-method input.clj /^(defmethod test :test2 named-method$/;" m multimethod.test | ||
test input.clj /^(defmulti test$/;" M multimethod.test | ||
test input.clj /^(defmethod test nil$/;" m multimethod.test | ||
test input.clj /^(defmethod test :test$/;" m multimethod.test | ||
test input.clj /^(defmethod test :test2 named-method$/;" m multimethod.test |
This file contains 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 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,6 @@ | ||
const-var input.clj /^(def const-var ^:const 'var)$/;" v namespace:vars.test | ||
doc-var input.clj /^(def doc-var "Documentation" 'var)$/;" v namespace:vars.test | ||
dynamic-var input.clj /^(def dynamic-var ^:dynamic 'var)$/;" v namespace:vars.test | ||
fn-var input.clj /^(def fn-var (fn [] true))$/;" f namespace:vars.test | ||
once-var input.clj /^(defonce once-var 'evaluated-once)$/;" v namespace:vars.test | ||
var input.clj /^(def var 'var)$/;" v namespace:vars.test |
This file contains 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)) |
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!