File tree Expand file tree Collapse file tree 2 files changed +26
-8
lines changed Expand file tree Collapse file tree 2 files changed +26
-8
lines changed Original file line number Diff line number Diff line change 122
122
path)]
123
123
(with-open [file-reader (or (some-> path-string FileReader.)
124
124
(some-> path-file FileReader.))]
125
- (parse/read-ns-decl (readers/indexing-push-back-reader
126
- (PushbackReader. file-reader))))))
125
+ (try
126
+ (parse/read-ns-decl (readers/indexing-push-back-reader
127
+ (PushbackReader. file-reader)))
128
+ (catch Exception _ nil )))))
127
129
([dialect path]
128
130
(let [^String path-string (when (string? path)
129
131
path)
130
132
^File path-file (when-not path-string
131
133
path)]
132
134
(with-open [file-reader (or (some-> path-string FileReader.)
133
135
(some-> path-file FileReader.))]
134
- (parse/read-ns-decl (readers/indexing-push-back-reader
135
- (PushbackReader. file-reader))
136
- {:read-cond :allow :features #{dialect}})))))
136
+ (try
137
+ (parse/read-ns-decl (readers/indexing-push-back-reader
138
+ (PushbackReader. file-reader))
139
+ {:read-cond :allow :features #{dialect}})
140
+ (catch Exception _ nil ))))))
137
141
138
142
(defn- data-file?
139
143
" True of f is named like a clj file but represents data.
Original file line number Diff line number Diff line change 1
1
(ns refactor-nrepl.core-test
2
- (:require [clojure.test :refer [deftest is testing]]
3
- [refactor-nrepl.config :as config]
4
- [refactor-nrepl.core :refer [ignore-dir-on-classpath?]]))
2
+ (:require
3
+ [clojure.test :refer [are deftest is testing]]
4
+ [refactor-nrepl.config :as config]
5
+ [refactor-nrepl.core :refer [ignore-dir-on-classpath? read-ns-form]])
6
+ (:import
7
+ (java.io File)))
5
8
6
9
(defmacro assert-ignored-paths
7
10
[paths pred]
24
27
[#".+checkouts/.+" #"resources" ])]
25
28
(assert-ignored-paths not-ignored false ?)
26
29
(assert-ignored-paths (concat always-ignored sometimes-ignored) true ?)))))
30
+
31
+ (deftest test-read-ns-form
32
+ (are [input expected] (testing input
33
+ (assert (-> input File. .exists))
34
+ (is (= expected
35
+ (read-ns-form input)))
36
+ true )
37
+ " test-resources/readable_file_incorrect_aliases.clj" nil
38
+ " testproject/src/com/example/one.clj" '(ns com.example.one
39
+ (:require [com.example.two :as two :refer [foo]]
40
+ [com.example.four :as four]))))
You can’t perform that action at this time.
0 commit comments