-
Notifications
You must be signed in to change notification settings - Fork 134
Fix parsing ns :require vectors with #_ comments #416
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| replace-newlines wrap-normalize-newlines | ||
| realign-form unalign-form]] | ||
| [cljfmt.test-util.common] | ||
| [clojure.string :as str] | ||
| [rewrite-clj.node :as n] | ||
| [rewrite-clj.parser :as p]) | ||
| #?(:cljs (:require-macros [cljfmt.test-util.cljs]))) | ||
|
|
@@ -323,24 +324,36 @@ | |
| "#_:clj-kondo/ignore " | ||
| "^tag " | ||
| "#_old-thing "] | ||
| ns-vec-str [(str ignore-str "[thing.core :as t]") | ||
| (str ignore-str "[thing [core :as t]]") | ||
| (str ignore-str "(thing [core :as t])") | ||
| (str "[" ignore-str "thing.core :as t]") | ||
| (str ignore-str " [" ignore-str "thing.core :as t]")] | ||
| :let [ns-str (str "(ns example (:require " ns-vec-str "))")]] | ||
| (testing ns-str | ||
| require-str ["<>[<>thing.core :as <>t :refer <>[<>my-defn]]" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There would have been over 5000 variations getting tested here if we did just put the metadata or uneval |
||
| "<>[<>thing <>[<>core :as <>t :refer <>[<>my-defn]]]"] | ||
| :let [ns-str (str "(ns my-namespace (:require " require-str "))")] | ||
| ns-str [ns-str | ||
| (-> ns-str | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try with both vectors for everything and lists for everything since either is allowed I guess, but change everything at once so we don't end up with too much of a combinatorial explosion |
||
| (str/replace #"\[" "(") | ||
| (str/replace #"\]" ")"))] | ||
| ns-str [(str/replace ns-str #"<>" ignore-str) | ||
| (str/replace ns-str #"<>" (str ignore-str ignore-str))]] | ||
|
Comment on lines
+334
to
+335
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found another bug where multiple metadata forms e.g. |
||
| (testing (str \newline (pr-str ns-str)) | ||
| (is (reformats-to? | ||
| [ns-str | ||
| "" | ||
| "(t/defn foo [x]" | ||
| "(+ x 1))" | ||
| "" | ||
| "(my-defn foo [x]" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to also test |
||
| "(+ x 1))"] | ||
| [ns-str | ||
| "" | ||
| "(t/defn foo [x]" | ||
| " (+ x 1))" | ||
| "" | ||
| "(my-defn foo [x]" | ||
| " (+ x 1))"] | ||
| {:indents {'ns [[:block 1]], 'thing.core/defn [[:inner 0]]} | ||
| #?@(:cljs [:alias-map {"t" "thing.core"}])}))))) | ||
| {:indents {'ns [[:block 1]] | ||
| 'thing.core/defn [[:inner 0]] | ||
| 'thing.core/my-defn [[:inner 0]]} | ||
| #?@(:cljs [:alias-map {"t" "thing.core"} | ||
| :refer-map {"my-defn" "thing.core"}])}))))) | ||
| (is (reformats-to? | ||
| ["(comment)" | ||
| "(ns thing.core)" | ||
|
|
||
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.
refer-vecwas incorrect sincexin:refer xcan be either a list or a vector