-
Notifications
You must be signed in to change notification settings - Fork 177
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
Cider's namespaces and vars filtered from ns-list and apropos #347
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 |
---|---|---|
|
@@ -41,7 +41,7 @@ | |
|
||
(defn inlined-dependency? | ||
"Returns true if the namespace matches one of our, or eastwood's, | ||
inlined dependencies." | ||
inlined dependencies." | ||
[namespace] | ||
(let [ns-name (str (ns-name namespace))] | ||
(or | ||
|
@@ -52,11 +52,22 @@ | |
;; rewritten by dolly | ||
(.startsWith ns-name "eastwood.copieddeps")))) | ||
|
||
(defn internal-namespace? | ||
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. This is just a regex matcher on a list now. But I think this name makes it easier to read functions where this is used. |
||
"Returns true if the namespace matches the given prefixes." | ||
[namespace & [prefixes]] | ||
(let [ns-name (str (ns-name namespace))] | ||
(->> prefixes | ||
(map re-pattern) | ||
(map #(re-find % ns-name)) | ||
(some (complement nil?))))) | ||
|
||
(defn loaded-namespaces | ||
"Return all loaded namespaces, except those coming from inlined dependencies." | ||
[] | ||
"Return all loaded namespaces, except those coming from inlined dependencies. | ||
`filter-regexps` is used to filter out namespaces matching regexps." | ||
[& [filter-regexps]] | ||
(->> (all-ns) | ||
(remove inlined-dependency?) | ||
(remove #(internal-namespace? % filter-regexps)) | ||
(map ns-name) | ||
(map name) | ||
(sort))) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,10 @@ | |
(deftest test-project-namespaces | ||
(is (contains? (into #{} (n/project-namespaces)) | ||
'cider.nrepl.middleware.util.namespace))) | ||
|
||
(deftest test-loaded-namespaces | ||
;; If we don't pass the second arg, some cider ns will be returned | ||
(is (some #(re-find #".*nrepl" %) (n/loaded-namespaces))) | ||
;; Shouldn't return any cider.nrepl namespaces | ||
(is (not-any? #(re-find #".*nrepl" %) | ||
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. @Malabarba Changed it :-) . I got an email about your comment. But cannot actually see it on GH. Weird. 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 think the comment was on a commit. The rebase must have cleared everything. |
||
(n/loaded-namespaces [".*nrepl"])))) |
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.
I would still have the inlided-deps filtered separately for clarity's sake.