cljfmt
cljfmt copied to clipboard
`extend-protocol`/`defprotocol`/etc. incorrectly uses indentation specs for method names
There seems to be a problem with [[:inner 1]] indentation handling when you have a indentation spec defined that matches the form symbol inside something like
extend-protocolor
defprotocol`. E.g. if you have a config like
{:extra-indents '{my.namespace/with-x [[:block 0]]}}
Then a file like
(ns my.namespace)
(defprotocol MyProtocol
MyClass
(with-x [this x]
"with-x is a method"))
(extend-protocol MyProtocol
MyClass
(with-x [this x]
(+ this x)))
Gets reformatted to
(ns my.namespace)
(defprotocol MyProtocol
MyClass
(with-x [this x]
"with-x is a method"))
(extend-protocol MyProtocol
MyClass
(with-x [this x]
(+ this x)))
It's using the [[:block 0]]
spec for my.namespace/with-x
rather than respecting the [:inner 1]
rules specified for defprotocol
and extend-protocol
.
Failing test:
(is (reformats-to?
["(ns my.namespace)"
""
"(defprotocol MyProtocol"
"MyClass"
"(with-x [this x]"
"\"with-x is a method\"))"
""
"(extend-protocol MyProtocol"
"MyClass"
"(with-x [this x]"
"(+ this x)))"]
["(ns my.namespace)"
""
"(defprotocol MyProtocol"
" MyClass"
" (with-x [this x]"
" \"with-x is a method\"))"
""
"(extend-protocol MyProtocol"
" MyClass"
" (with-x [this x]"
" (+ this x)))"]
{:extra-indents '{my.namespace/with-x [[:block 0]]}}))