From ebebae3704d5a04e8da792dedc8ccb5512689b87 Mon Sep 17 00:00:00 2001 From: Rohit Patnaik Date: Sun, 22 Jan 2023 09:36:27 -0600 Subject: [PATCH] Flag special forms and macros as themselves. Instead of treating special-forms and macros as functions, we should send them as special-forms and macros, respectively, so that CIDER (and other clients) can properly handle the arglists. --- src/orchard/eldoc.clj | 6 +++++- test/orchard/eldoc_test.clj | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/orchard/eldoc.clj b/src/orchard/eldoc.clj index ab06f34f..04a7dc31 100644 --- a/src/orchard/eldoc.clj +++ b/src/orchard/eldoc.clj @@ -37,7 +37,11 @@ (defn- extract-eldoc [info] (if-let [arglists (seq (-> info extract-arglists format-arglists))] - {:eldoc arglists :type "function"} + {:eldoc arglists + :type (cond + (:special-form info) "special-form" + (:macro info) "macro" + :else "function")} {:type "variable"})) (defn eldoc diff --git a/test/orchard/eldoc_test.clj b/test/orchard/eldoc_test.clj index be7925f8..d20b0504 100644 --- a/test/orchard/eldoc_test.clj +++ b/test/orchard/eldoc_test.clj @@ -43,6 +43,18 @@ (is (:eldoc result)) (is (:docstring result)))) + (testing "Clojure special form" + (let [result (eldoc/eldoc (info/info 'clojure.core 'if))] + (is (= (:type result) "special-form")))) + + (testing "Clojure macro" + (let [result (eldoc/eldoc (info/info 'clojure.core 'when))] + (is (= (:type result) "macro")))) + + (testing "Clojure function" + (let [result (eldoc/eldoc (info/info 'clojure.core 'inc))] + (is (= (:type result) "function")))) + (testing "Java result structure" (let [result (eldoc/eldoc (info/info-java 'java.lang.String 'toLowerCase))] (is (:class result))