Skip to content

Commit

Permalink
Recompute namespace info on each fighweel-main recompilation
Browse files Browse the repository at this point in the history
Similar to #3396, except that it's only necessary on recompilation - not on evaluations.
  • Loading branch information
vemv committed Aug 12, 2023
1 parent 7dd9470 commit 8ffd7df
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
- [#3383](https://github.com/clojure-emacs/cider/issues/3383): `cider-connect-clj&cljs`: don't render `"ClojureScript REPL type:"` for JVM repls.
- [#3331](https://github.com/clojure-emacs/cider/issues/3331): `cider-eval`: never jump to spurious locations, as sometimes conveyed by nREPL.
- [#3112](https://github.com/clojure-emacs/cider/issues/3112): Fix the CIDER `xref-find-references` backend to return correct filenames.
- [#3393](https://github.com/clojure-emacs/cider/issues/3393): recompute namespace info on each shadow-cljs recompilation or evaluation.
- [#3393](https://github.com/clojure-emacs/cider/issues/3393): Recompute namespace info on each shadow-cljs recompilation or evaluation.
- Recompute namespace info on each fighweel-main recompilation.
- Fix the `xref-find-definitions` CIDER backend to return correct filenames.
- Fix the `cider-xref-fn-deps` buttons to direct to the right file.

Expand Down
22 changes: 19 additions & 3 deletions cider-repl.el
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,11 @@ t, as the content-type response is (currently) an alternative to the
value response. However for handlers which themselves issue subsequent
nREPL ops, it may be convenient to prevent inserting a prompt.")

(defun cider--maybe-get-state-cljs ()
(when-let ((conn (cider-current-repl 'cljs)))
(when (nrepl-op-supported-p "cider/get-state" conn)
(nrepl-send-request '("op" "cider/get-state") nil conn))))

(defun cider--maybe-get-state-for-shadow-cljs (buffer &optional err)
"Refresh the changed namespaces metadata given BUFFER and ERR (stderr string).
Expand All @@ -1003,9 +1008,16 @@ This is particularly necessary for shadow-cljs because:
(if err
(string-match-p "Build completed\\." err)
t))
(when-let ((conn (cider-current-repl 'cljs)))
(when (nrepl-op-supported-p "cider/get-state" conn)
(nrepl-send-request '("op" "cider/get-state") nil conn))))))
(cider--maybe-get-state-cljs))))

(defun cider--maybe-get-state-for-figwheel-main (buffer out)
"Refresh the changed namespaces metadata given BUFFER and OUT (stdout string)."
(with-current-buffer buffer
(when (and (eq cider-repl-type 'cljs)
(eq cider-cljs-repl-type 'figwheel-main)
(not cider-repl-cljs-upgrade-pending)
(string-match-p "Successfully compiled build" out))
(cider--maybe-get-state-cljs))))

(defun cider--shadow-cljs-handle-stderr (buffer err)
"Refresh the changed namespaces metadata given BUFFER and ERR."
Expand All @@ -1015,6 +1027,8 @@ This is particularly necessary for shadow-cljs because:
"Refresh the changed namespaces metadata given BUFFER."
(cider--maybe-get-state-for-shadow-cljs buffer))

(defvar cider--repl-stdout-functions (list #'cider--maybe-get-state-for-figwheel-main))

(defvar cider--repl-stderr-functions (list #'cider--shadow-cljs-handle-stderr)
"Functions to be invoked each time new stderr is received on a repl buffer.
Expand All @@ -1032,6 +1046,8 @@ and responding to them.")
(lambda (buffer value)
(cider-repl-emit-result buffer value t))
(lambda (buffer out)
(dolist (f cider--repl-stdout-functions)
(funcall f buffer out))
(cider-repl-emit-stdout buffer out))
(lambda (buffer err)
(dolist (f cider--repl-stderr-functions)
Expand Down

0 comments on commit 8ffd7df

Please sign in to comment.