[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/cider fb2bcd9438 1/9: Fix the CIDER `xref-find-references`
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/cider fb2bcd9438 1/9: Fix the CIDER `xref-find-references` backend to return correct filenames |
Date: |
Fri, 11 Aug 2023 06:59:14 -0400 (EDT) |
branch: elpa/cider
commit fb2bcd94383fe0318db1c69cc4b2c1b27b2c4646
Author: vemv <vemv@users.noreply.github.com>
Commit: Bozhidar Batsov <bozhidar@batsov.dev>
Fix the CIDER `xref-find-references` backend to return correct filenames
Fixes https://github.com/clojure-emacs/cider/issues/3112
---
CHANGELOG.md | 2 ++
cider-find.el | 45 +++++++++++++++++++++++++++++++++++++--------
2 files changed, 39 insertions(+), 8 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 623b739429..07dc5ce9dd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,8 @@
- [#3236](https://github.com/clojure-emacs/cider/issues/3236):
`cider-repl-set-ns` no longer changes the repl session type from `cljs:shadow`
to `clj`.
- [#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.
+
### Changes
diff --git a/cider-find.el b/cider-find.el
index 6e882ae3f4..b644776b0b 100644
--- a/cider-find.el
+++ b/cider-find.el
@@ -30,6 +30,7 @@
(require 'cider-common)
(require 'cider-resolve)
+(require 'seq)
(require 'thingatpt)
(defun cider--find-var-other-window (var &optional line)
@@ -275,14 +276,42 @@ thing at point."
(cider-ensure-connected)
(cider-ensure-op-supported "fn-refs")
(when-let* ((ns (cider-current-ns))
- (results (cider-sync-request:fn-refs ns var)))
- (mapcar (lambda (info)
- (let* ((filename (nrepl-dict-get info "file"))
- (column (nrepl-dict-get info "column"))
- (line (nrepl-dict-get info "line"))
- (loc (xref-make-file-location filename line column)))
- (xref-make filename loc)))
- results)))
+ (results (cider-sync-request:fn-refs ns var))
+ (previously-existing-buffers (buffer-list)))
+ (thread-last results
+ (mapcar (lambda (info)
+ (let* ((filename (cider--xref-extract-file info))
+ (column (nrepl-dict-get info "column"))
+ (line (nrepl-dict-get info "line"))
+ (friendly-name
(cider--xref-extract-friendly-file-name info))
+ ;; translate .jar urls and such:
+ (buf (cider--find-buffer-for-file filename))
+ (bfn (and buf (buffer-file-name buf)))
+ (loc (when buf
+ ;; favor `xref-make-file-location'
when possible, since that way, we can close their buffers.
+ (if bfn
+ (xref-make-file-location bfn line
(or column 0))
+ (xref-make-buffer-location buf
(with-current-buffer buf
+
(save-excursion
+
(goto-char 0)
+
(forward-line line)
+
(move-to-column (or column 0))
+
(point)))))))
+ (should-be-closed? (and
+ buf
+ ;; if a buffer did not
exist before,
+ ;; then it is a
side-effect of invoking `cider--find-buffer-for-file'.
+ (not (member buf
previously-existing-buffers))
+ bfn
+ ;; only buffers with a
normally reachable filename are safe to close.
+ ;; buffers not backed by
such files may include .jars, TRAMP files, etc.
+ ;; Sadly this means we
will still 'leak' some open buffers, but it's what we can do atm.
+ (file-exists-p bfn))))
+ (when should-be-closed?
+ (kill-buffer buf))
+ (when loc
+ (xref-make friendly-name loc)))))
+ (seq-filter #'identity))))
(cl-defmethod xref-backend-apropos ((_backend (eql cider)) pattern)
"Find all symbols that match regexp PATTERN."
- [nongnu] elpa/cider updated (cf671a8b10 -> f376d2de9d), ELPA Syncer, 2023/08/11
- [nongnu] elpa/cider e957b937a3 2/9: Fix the `cider-xref-fn-deps` buttons to direct to the right file, ELPA Syncer, 2023/08/11
- [nongnu] elpa/cider 816f047767 3/9: Fix the `xref-find-definitions` CIDER backend to return correct filenames, ELPA Syncer, 2023/08/11
- [nongnu] elpa/cider a9e710a556 6/9: Remove now-unused requires, document used one, ELPA Syncer, 2023/08/11
- [nongnu] elpa/cider 7806de25a5 4/9: Improve the presentation of `xref` data, ELPA Syncer, 2023/08/11
- [nongnu] elpa/cider 37de49a76d 8/9: Recompute namespace info on each shadow-cljs recompilation or evaluation (#3396), ELPA Syncer, 2023/08/11
- [nongnu] elpa/cider f376d2de9d 9/9: Enhance `cider-connect` to show all nREPLs available ports, instead of only Leiningen ones (#3399), ELPA Syncer, 2023/08/11
- [nongnu] elpa/cider 65410fec14 7/9: `should-be-closed?` -> `should-be-closed`, ELPA Syncer, 2023/08/11
- [nongnu] elpa/cider 52766a0bf1 5/9: Extract cider-xref-backend.el, ELPA Syncer, 2023/08/11
- [nongnu] elpa/cider fb2bcd9438 1/9: Fix the CIDER `xref-find-references` backend to return correct filenames,
ELPA Syncer <=