You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For defprotocols with both :extend-via-metadata true and a docstring, Cursive fails to parse when the docstring comes after the other options for the defprotocol.
I was initially a little confused becuase the docs for defprotocol do make it seem like the docstring should come first, but the implementation is written to acommodate either order and I've found docstring-after in the wild (for example, here in next.jdbc)
(defmacrodefprotocol"A protocol is a named set of named methods and their signatures: (defprotocol AProtocolName ;optional doc string"AdocstringforAProtocolabstraction" ;options :extend-via-metadata true ;method signatures (bar [this a b] "bardocs") (baz [this a] [this a b] [this a b c] "bazdocs")) ..." ,,,)
Environment
IntelliJ IDEA: 2020.2.1
Cursive: 1.9.4-eap3-2020.2
Steps to reproduce
Add this to any namespace and edit with Cursive:
;; Docstring AFTER other deprotocol options = sad cursive
(defprotocolProtocolAfter:extend-via-metadatatrue"docstring is after options"
(demo-after [this]))
(defrecordRecordAfter []
ProtocolAfter
(demo-after [this] "broken"))
(println"demo-after record:" (demo-after (RecordAfter.)))
(let [o (with-meta {} {`demo-after (constantly"also broken")})]
(println"demo-after with-meta:" (demo-after o)))
;; Docstring BEFORE other deprotocol options = just fine
(defprotocolProtocolBefore"docstring is before options":extend-via-metadatatrue
(demo-before [this]))
(defrecordRecordBefore []
ProtocolBefore
(demo-before [this] "working"))
(println"demo-before record:" (demo-before (RecordBefore.)))
(let [o (with-meta {} {`demo-before (constantly"also working")})]
(println"demo-before with-meta:" (demo-before o)))
Load and evaluate the NS in your REPL just to make sure that the metadata extension is functioning as expected:
demo-after record: broken
demo-after with-meta: also broken
demo-before record: working
demo-before with-meta: also working
See that Cursive is not resolving the first protocol, which was defined with a docstring after :extend-via-metadata true
Expected behavior
Cursive can understand defprotocols regardless of whether the docstring comes before or after :extend-via-metadata true.
The text was updated successfully, but these errors were encountered:
For
defprotocols
with both:extend-via-metadata true
and a docstring, Cursive fails to parse when the docstring comes after the other options for thedefprotocol
.I was initially a little confused becuase the docs for
defprotocol
do make it seem like the docstring should come first, but the implementation is written to acommodate either order and I've found docstring-after in the wild (for example, here innext.jdbc
)Environment
2020.2.1
1.9.4-eap3-2020.2
Steps to reproduce
Add this to any namespace and edit with Cursive:
Load and evaluate the NS in your REPL just to make sure that the metadata extension is functioning as expected:
See that Cursive is not resolving the first protocol, which was defined with a docstring after
:extend-via-metadata true
Expected behavior
Cursive can understand defprotocols regardless of whether the docstring comes before or after
:extend-via-metadata true
.The text was updated successfully, but these errors were encountered: