Skip to content

Commit

Permalink
Fix for #47
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Apr 7, 2019
1 parent 8a68f72 commit 5987b5a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/clj_kondo/impl/vars.clj
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
(loop [[child & rest-children] children
stripped []]
(if child
(if (contains? '#{:meta} (node/tag child))
(if (contains? '#{:meta :meta*} (node/tag child))
(recur rest-children
(into stripped (strip-meta* (rest (:children child)))))
(recur rest-children
Expand All @@ -133,6 +133,7 @@
;; TODO: add metadata parsing for private
private? (= 'defn- (some-call expr defn-))
children (rest children)
children (strip-meta* children)
fn-name (:value (first (filter #(symbol? (:value %)) children)))
arg-decl (first (filter #(= :vector (:tag %)) children))
arg-decls (map (fn [x]
Expand Down Expand Up @@ -388,7 +389,7 @@
(get-in idacs [:cljc :defns fn-ns (:lang call) fn-name])
(when (and
(not (:clojure-excluded? call))
(= (:ns call)
(= caller-ns
fn-ns))
(core-lookup clojure-core-defns cljs-core-defns
lang fn-name)))
Expand All @@ -402,7 +403,7 @@
;; call and the lang of the function def context in
;; the case of in-ns, the bets are off. we may
;; support in-ns in a next version.
valid-order? (if (and (= (:ns call)
valid-order? (if (and (= caller-ns
fn-ns)
(= (:base-lang call)
(:base-lang called-fn)))
Expand All @@ -428,7 +429,7 @@
(str (:arity call) #_#_" " called-fn)
(:qname called-fn))})
(when (and (:private? called-fn)
(not= (:ns call)
(not= caller-ns
fn-ns))
{:filename filename
:row (:row call)
Expand Down
15 changes: 13 additions & 2 deletions test/clj_kondo/impl/vars_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,19 @@
(is (every? true?
(map submap?
'[{:type :defn, :name chunk-buffer, :fixed-arities #{1}}
{:type :call, :name clojure.lang.ChunkBuffer., :arity 1, :row 2, :col 3}](vars/parse-defn :clj #{} (parse-string "(defn ^:static ^clojure.lang.ChunkBuffer chunk-buffer ^clojure.lang.ChunkBuffer [capacity]
(clojure.lang.ChunkBuffer. capacity))"))))))
{:type :call, :name clojure.lang.ChunkBuffer., :arity 1, :row 2, :col 3}]
(vars/parse-defn :clj #{}
(parse-string
"(defn ^:static ^clojure.lang.ChunkBuffer chunk-buffer ^clojure.lang.ChunkBuffer [capacity]
(clojure.lang.ChunkBuffer. capacity))")))))
(is (= '({:type :defn,
:name get-bytes,
:row 1,
:col 1,
:lang :clj,
:fixed-arities #{1}})
(vars/parse-defn :clj #{}
(parse-string "(defn get-bytes #^bytes [part] part)")))))

(deftest analyze-ns-test
(is
Expand Down

0 comments on commit 5987b5a

Please sign in to comment.