jacktasia / dumb-jump

an Emacs "jump to definition" package for 50+ languages
GNU General Public License v3.0
1.57k stars 150 forks source link

dumb-jump doesn't find all clojure definitions #438

Closed npcoder2k14 closed 1 year ago

npcoder2k14 commented 1 year ago

Consider the function is listed in the following way -

(defn ^:metadata hello-world
  []
  (println "hello world"))

and called in the following way -

(hello-world)

On invoking the xref-find-definitions function on hello-world. It doesn't list the above defined function.

The same happens when you try to find tags defined by deftest. Eg: -

(deftest hello-test
 ;;
)
npcoder2k14 commented 1 year ago

After debugging it for a bit, I found out the regular expressions used are inadequate to support the above use-cases.

Regexes present in dumb-jump.el file -

 (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "clojure"
           :regex "\\(def\\s+JJJ\\j"
           :tests ("(def test (foo)"))

    (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "clojure"
           :regex "\\(defn-?\\s+JJJ\\j"
           :tests ("(defn test [foo]" "(defn- test [foo]")
           :not ("(defn test? [foo]" "(defn- test? [foo]"))

    (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "clojure"
           :regex "\\(defmacro\\s+JJJ\\j"
           :tests ("(defmacro test [foo]"))

    (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "clojure"
           :regex "\\(deftask\\s+JJJ\\j"
           :tests ("(deftask test [foo]"))

    (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "clojure"
           :regex "\\(deftype\\s+JJJ\\j"
           :tests ("(deftype test [foo]"))

    (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "clojure"
           :regex "\\(defmulti\\s+JJJ\\j"
           :tests ("(defmulti test fn"))

    (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "clojure"
           :regex "\\(defmethod\\s+JJJ\\j"
           :tests ("(defmethod test type"))

    (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "clojure"
           :regex "\\(definterface\\s+JJJ\\j"
           :tests ("(definterface test (foo)"))

    (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "clojure"
           :regex "\\(defprotocol\\s+JJJ\\j"
           :tests ("(defprotocol test (foo)"))

    (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "clojure"
           :regex "\\(defrecord\\s+JJJ\\j"
           :tests ("(defrecord test [foo]"))