clojure-emacs / orchard

A fertile ground for Clojure tooling
Eclipse Public License 1.0
323 stars 54 forks source link

Cider-doc cannot lookup Closure and other Clojurescript dependencies #203

Open derinsh0 opened 1 year ago

derinsh0 commented 1 year ago

Expected behavior

Cider-doc should resolve symbols from dependencies such as Google Closure and attempt to evaluate their doc-string if no other source of documentation is available.

Actual behavior

Running cider-doc on the function goog.dom/createElement will give "symbol not resolved".

But that function has a valid, if somewhat crude, docstring that cider can evaluate with (:doc (meta #'goog.dom/createElement)) or (clojure.repl/doc goog.dom/createElement) which gives:

-------------------------
goog.dom/createElement
([name])
  /**
 * Creates a new element.
 * @param {string|!goog.dom.TagName<T>} name Tag to create.
 * @return {R} The new element. The return type is {!Element} if name is
 *     a string or a more specific type if it is a member of goog.dom.TagName
 *     (e.g. {!HTMLAnchorElement} for goog.dom.TagName.A).
 * @template T
 * @template R := cond(isUnknown(T), 'Element', T) =:
 */
nil

As a comparison. Function meta is lookable with cider-doc. Which opens:

cljs.core/meta [o] Returns the metadata of obj, returns nil if there is no metadata.

cljs.core/meta is defined in

jar:file:/C:/Users/x/.m2/repository/org/clojure/clojurescript/1.11.4/clojurescript-1.11.4.jar!/cljs/core.cljs.

But evaluating (meta #'meta) says the function is located at :

{...
:file "cljs/core.cljs"
...}

While (meta #'goog.dom/createElement) :

:file "file:/C:/Users/x/.m2/repository/org/clojure/google-closure-library/0.0-20211011-0726fdeb/google-closure-library-0.0-20211011-0726fdeb.jar!/goog/dom/dom.js"

Maybe the issue is finding it?

Steps to reproduce the problem

Create a figwheel-main cljs project and jack-in with cider. Import namespace goog.dom and lookup any of its functions with cider-doc.

Environment & Version information

CIDER version information

;; CIDER 1.5.0-snapshot (package: 20220628.551), nREPL 0.9.0
;; Clojure 1.10.0, Java 17.0.3.1

Lein / Clojure CLI version

Clj win-install-1.11.1.1149.ps1

Emacs version

29.0.50

Operating system

Windows 10

JDK distribution

java version "17.0.3.1" 2022-04-22 LTS Java(TM) SE Runtime Environment (build 17.0.3.1+2-LTS-6) Java HotSpot(TM) 64-Bit Server VM (build 17.0.3.1+2-LTS-6, mixed mode, sharing)

P.S.

I don't know CIDER enough to decide if this is a bug or missing feature.

bbatsov commented 1 year ago

Can you post here the relevant message exchange with nREPL? (see https://docs.cider.mx/cider/troubleshooting.html#debugging-the-communication-with-nrepl)

derinsh0 commented 1 year ago

Can you post here the relevant message exchange with nREPL? (see https://docs.cider.mx/cider/troubleshooting.html#debugging-the-communication-with-nrepl)

Yes, but it doesn't say that much.

(-->
  id         "179"
  op         "eldoc"
  session    "e9fdf778-baa0-4512-9dc6-d8c200594826"
  time-stamp "2022-07-24 01:59:20.305304000"
  ns         #("lcljs.temp" 0 10 (cider-block-dynamic-font-lock t cider-locals nil help-echo cider--help-echo fontified nil))
  sym        "gdom/getElement"
)
(<--
  id         "179"
  session    "e9fdf778-baa0-4512-9dc6-d8c200594826"
  time-stamp "2022-07-24 01:59:20.314077000"
  status     ("done" "no-eldoc")
)
(-->
  id         "180"
  op         "info"
  session    "e9fdf778-baa0-4512-9dc6-d8c200594826"
  time-stamp "2022-07-24 01:59:23.149347000"
  ns         #("lcljs.temp" 0 10 (cider-block-dynamic-font-lock t cider-locals nil help-echo cider--help-echo fontified nil))
  sym        "gdom/getElement"
)
(<--
  id         "180"
  session    "e9fdf778-baa0-4512-9dc6-d8c200594826"
  time-stamp "2022-07-24 01:59:23.151240000"
  status     ("done" "no-info")
)
(-->
  id         "181"
  op         "eldoc"
  session    "e9fdf778-baa0-4512-9dc6-d8c200594826"
  time-stamp "2022-07-24 01:59:23.957024000"
  ns         #("lcljs.temp" 0 10 (cider-block-dynamic-font-lock t cider-locals nil help-echo cider--help-echo fontified nil))
  sym        "gdom/getElement"
)
(<--
  id         "181"
  session    "e9fdf778-baa0-4512-9dc6-d8c200594826"
  time-stamp "2022-07-24 01:59:23.966280000"
  status     ("done" "no-eldoc")
)

Cider-browse-ns won't find goog.dom either.

bbatsov commented 1 year ago

My guess would be that this doesn't work for JavaScript sources, but I don't do ClojureScript myself and I don't remember much of the relevant code in Orchard at this point. Perhaps @arichiardi can shed more light on this.

vemv commented 8 months ago

(moved from cider to Orchard)