Skip to content

Commit

Permalink
[Fix #196] Rewritten dependencies polluting ns-list
Browse files Browse the repository at this point in the history
Our own inlined deps, created by mranderson, as well as the inlined deps
from eastwood were polluting the result of the `ns-list` op.  These are
now filtered out.

This change improves all cider commands relying on a completing read of
some namespace e.g. `cider-browse-ns` and `cider-find-ns`
  • Loading branch information
expez committed Jun 11, 2015
1 parent e57a10e commit eab8973
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/cider/nrepl/middleware/ns.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,19 @@
[transport :as transport]])
(:import java.util.jar.JarFile))

(defn inlined-dependency?
[^String ns]
(or
;; rewritten by mranderson
(.startsWith ns "deps.")
;; rewritten by dolly
(.startsWith ns "eastwood.copieddeps")))

(defn ns-list-clj []
(->> (all-ns)
(map ns-name)
(map name)
(remove inlined-dependency?)
(sort)))

(defn ns-vars-clj [ns]
Expand Down
12 changes: 9 additions & 3 deletions test/clj/cider/nrepl/middleware/ns_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
[cider.nrepl.test-transport :refer [messages test-transport]]
[clojure.test :refer :all]))

(deftest test-toogle-ns-list
(is (= (count (all-ns)) (count (ns-list-clj)))))
(deftest test-toggle-ns-list
(is (= (count (all-ns))
(count
(remove #'cider-nrepl-middleware.ns/inlined-dependency? (ns-list-clj))))))

(deftest test-toogle-ns-vars
(let [ns "clojure.core"]
Expand All @@ -18,7 +20,11 @@
(deftest ns-list-integration-test
(let [ns-list (:ns-list (session/message {:op "ns-list"}))]
(is (sequential? ns-list))
(is (every? string? ns-list))))
(is (every? string? ns-list))
(testing "Removal of namespaces created by source rewriting"
(is (every? #(not (or (.startsWith % "deps.")
(.startsWith % "eastwood.copieddeps")))
ns-list)))))

(deftest ns-vars-integration-test
(let [ns-vars (:ns-vars (session/message {:op "ns-vars"
Expand Down

0 comments on commit eab8973

Please sign in to comment.