Skip to content

Commit 9605d18

Browse files
committed
Add override for xref-backend-references
Which will take the provided identifier and only search for the last segment (base name or method name), to synchronize with xref-backend-identifier-at-point.
1 parent e693fd3 commit 9605d18

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ Robe is a code assistance tool that uses a Ruby REPL subprocess with
44
your application or gem code loaded, to provide information about
55
loaded classes and modules, and where each method is defined.
66

7-
Generally, you'll want to start with `M-x inf-ruby-console-auto`.
8-
If there's no Ruby console running, most interactive commands provided
9-
by Robe will offer to launch it automatically.
7+
Generally, you'll want to start with `M-x inf-ruby-console-auto` or
8+
with `M-x robe-start` (which will offer to call the former function as
9+
well if there is no Ruby console running). Some interactive commands
10+
provided by Robe will also offer to launch it first.
1011

1112
The exceptions are code completion and eldoc, which only work if the
1213
server is already running. To launch it, type `M-x robe-start`.

robe.el

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ Only works with Rails, see e.g. `rinari-console'."
13461346
(robe-complete-symbol-p (car bounds)))
13471347
(buffer-substring (car bounds) (cdr bounds)))))
13481348

1349-
(defun robe--xref-backend () 'robe)
1349+
(defun robe--xref-backend () (and (robe-running-p) 'robe))
13501350

13511351
(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql 'robe)))
13521352
(let ((context (robe-context))
@@ -1379,8 +1379,6 @@ Only works with Rails, see e.g. `rinari-console'."
13791379
(cond
13801380
(at-pt
13811381
(or (robe--xref-variable-definition identifier (nth 3 context))
1382-
;; FIXME: Probably move this check to `robe--xref-backend'.
1383-
(ignore (robe-start))
13841382
(append
13851383
(robe--xref-method-definitions identifier context)
13861384
(robe--xref-module-definitions identifier (nth 1 context)))))
@@ -1431,6 +1429,11 @@ Only works with Rails, see e.g. `rinari-console'."
14311429
(list
14321430
(xref-make name var)))))
14331431

1432+
;; XXX: Search across the full LOAD_PATH as well?
1433+
(cl-defmethod xref-backend-references ((backend (eql 'robe)) identifier)
1434+
;; FIXME: Do more filtering by scope, to remove definite non-matches.
1435+
(cl-call-next-method backend (car (last (string-split identifier "::\\|#\\|\\.")))))
1436+
14341437
(cl-defmethod xref-location-marker ((var robe--variable))
14351438
(save-excursion
14361439
(save-restriction
@@ -1490,8 +1493,6 @@ Only works with Rails, see e.g. `rinari-console'."
14901493
(file-relative-name file dir)
14911494
file)))
14921495

1493-
;; TODO: `xref-backend-references' across LOAD_PATH.
1494-
14951496
(defvar robe-mode-map
14961497
(let ((map (make-sparse-keymap)))
14971498
(define-key map (kbd "C-c C-d") 'robe-doc)

0 commit comments

Comments
 (0)