2222 [lambdaisland.tools.namespace.track :as ctn-track]
2323 [slingshot.slingshot :refer [try+]]
2424 [nextjournal.beholder :as beholder])
25- (:import (java.nio.file FileSystems)
25+ (:import (java.io File)
26+ (java.nio.file FileSystems Path PathMatcher)
2627 (java.util.concurrent ArrayBlockingQueue BlockingQueue)))
2728
2829(defn make-queue []
9394 for a description of the patterns, these are similar but not the same as
9495 typical shell glob patterns."
9596 [path patterns]
97+ (assert (instance? Path path))
9698 (let [fs (FileSystems/getDefault )
9799 patterns (map #(.getPathMatcher fs (str " glob:" %)) patterns)]
98- (some #(.matches % path) patterns)))
100+ (some #(.matches ^PathMatcher % path) patterns)))
99101
100102(defn convert
101103 " Converts a Git-style ignore pattern into the equivalent pattern that Java PathMatcher uses."
153155 " Finds ignore files in the local directory and the system."
154156 [dir]
155157 (let [absolute-files [(io/file (str (System/getProperty " user.home" ) " /.config/git/ignore" ))]
156- relative-files (filter #(glob? (.toPath %) [" **.gitignore" " **.ignore" ]) (file-seq (io/file dir)))]
158+ relative-files (filter #(glob? (.toPath ^File %) [" **.gitignore" " **.ignore" ]) (file-seq (io/file dir)))]
157159 (into absolute-files relative-files)))
158160
159161(defn merge-ignore-files
169171(defn wait-and-rescan! [q tracker watch-paths ignore]
170172 (let [f (qtake q)]
171173 (cond
172- (and (file? f) (glob? (.toPath f) ignore))
174+ (and (file? f) (glob? (.toPath ^File f) ignore))
173175 (recur q tracker watch-paths ignore)
174176
175177 (directory? f)
@@ -281,7 +283,7 @@ errors as test errors."
281283 (map io/file))
282284 (:kaocha/tests config))
283285 ; ; Without this, if any path doesn't exist the watching doesn't work.
284- (filter (fn [x] (.exists ^java.io. File x)))))
286+ (filter (fn [x] (.exists ^File x)))))
285287
286288(defmulti watch! :type )
287289
@@ -295,8 +297,9 @@ errors as test errors."
295297(defmethod watch! :beholder [{:keys [q watch-paths]}]
296298 (apply beholder/watch
297299 (fn [{:keys [type path]}]
300+ (assert (instance? Path path))
298301 (when (contains? #{:modify :create } type)
299- (qput q path)))
302+ (qput q ( .toFile ^Path path) )))
300303 (map str watch-paths)))
301304
302305(defn run* [config finish? q]
@@ -307,7 +310,7 @@ errors as test errors."
307310 {})
308311 watch-paths (if (:kaocha.watch/use-ignore-file config)
309312 (set/union (watch-paths config)
310- (set (map #(.getParentFile (.getCanonicalFile %)) (find-ignore-files " ." ))))
313+ (set (map #(.getParentFile (.getCanonicalFile ^File %)) (find-ignore-files " ." ))))
311314 (watch-paths config))
312315 tracker (ctn-track/tracker )
313316 ; ; if t.n fails due to circular dependencies, do not track-reload.
0 commit comments