Skip to content

Commit

Permalink
Merge pull request #17 from ninjudd/handle_empty_slash
Browse files Browse the repository at this point in the history
Handle slash without anything before it
  • Loading branch information
ninjudd committed Jan 21, 2014
2 parents e106888 + cb31512 commit 76d4bda
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/complete/core.clj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -95,12 +95,13 @@


(defmethod potential-completions :scoped (defmethod potential-completions :scoped
[prefix ns] [prefix ns]
(let [scope (symbol (first (.split prefix "/")))] (when-let [prefix-scope (first (.split prefix "/"))]
(map #(str scope "/" %) (let [scope (symbol prefix-scope)]
(if-let [class (resolve-class scope)] (map #(str scope "/" %)
(static-members class) (if-let [class (resolve-class scope)]
(when-let [ns (or (find-ns scope) (scope (ns-aliases ns)))] (static-members class)
(ns-public-vars ns)))))) (when-let [ns (or (find-ns scope) (scope (ns-aliases ns)))]
(ns-public-vars ns)))))))


(defmethod potential-completions :class (defmethod potential-completions :class
[prefix ns] [prefix ns]
Expand Down
4 changes: 4 additions & 0 deletions test/complete/core_test.clj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
(is (= '("java.lang.System/out") (is (= '("java.lang.System/out")
(completions "java.lang.System/out"))) (completions "java.lang.System/out")))


(is (= () (completions "fake-ns-here/")))

(is (= () (completions "/")))

(is (some #{"String/valueOf"} (completions "String/"))) (is (some #{"String/valueOf"} (completions "String/")))


(is (not (some #{"String/indexOf" ".indexOf"} (completions "String/"))))) (is (not (some #{"String/indexOf" ".indexOf"} (completions "String/")))))

0 comments on commit 76d4bda

Please sign in to comment.