File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 22
33## Unreleased
44
5+ * [ #294 ] ( https://github.com/clojure-emacs/refactor-nrepl/pull/294 ) : Properly skip uneval nodes when looking for the first/last sexp
6+
57## 2.5.1 (2021-02-16)
68
79### Bugs fixed
Original file line number Diff line number Diff line change 88 [zipper]
99 (take-while (complement zip/end?) (iterate zip/next zipper)))
1010
11- (defn- comment-or-string-or-nil? [zloc]
11+ (defn- comment-or-string-or-uneval-or- nil? [zloc]
1212 (or (nil? zloc)
13+ (= :uneval (zip/tag zloc))
1314 (not (zip/sexpr zloc)) ; comment node
1415 (string? (zip/sexpr zloc))))
1516
1819 (let [reader (zip-reader/string-reader file-content)]
1920 (loop [sexp (zip-parser/parse reader)]
2021 (let [zloc (zip/edn sexp)]
21- (if (and zloc (not (comment-or-string-or-nil? zloc)))
22+ (if (and zloc (not (comment-or-string-or-uneval-or- nil? zloc)))
2223 (zip/string zloc)
2324 (when (.peek-char reader)
2425 (recur (zip-parser/parse reader))))))))
2526
2627(defn get-last-sexp
2728 ^String [file-content]
2829 (let [zloc (->> file-content zip/of-string zip/rightmost)]
29- (some (fn [zloc] (when-not (comment-or-string-or-nil? zloc)
30+ (some (fn [zloc] (when-not (comment-or-string-or-uneval-or- nil? zloc)
3031 (zip/string zloc)))
3132 (take-while (complement nil?) (iterate zip/left zloc)))))
3233
Original file line number Diff line number Diff line change 1010 #{foo bar baz}
1111 ;; some other stuff
1212 (foobar baz)" )
13+ (def file-content-with-uneval " #_ foo
14+ (foobar baz)" )
15+
1316(def binding-location [3 8 ])
1417(def set-location [7 35 ])
1518(def map-location [7 28 ])
3336 (apply sut/get-enclosing-sexp file-content when-not-location )))
3437 (t/is (= nil (sut/get-first-sexp weird-file-content)))
3538 (t/is (= " #{foo bar baz}" (sut/get-first-sexp file-content-with-set))))
39+
40+ (t/deftest get-first-sexp
41+ (t/is (= " (ns resources.testproject.src.com.example.sexp-test)"
42+ (sut/get-first-sexp file-content)))
43+ (t/is (= " (foobar baz)"
44+ (sut/get-first-sexp file-content-with-uneval))))
You can’t perform that action at this time.
0 commit comments