Rename xref-collect-references and xref-collect-matches
* lisp/progmodes/xref.el (xref-references-in-directory): Rename from xref-collect-references. Update the sole caller. (xref-matches-in-directory): Rename from xref-collect-matches. Update all callers (all of them are in the /tests/ dir). * test/lisp/progmodes/xref-tests.el (xref-tests-data-dir): Don't use the EMACS_TEST_DIRECTORY env var. It doesn't work when running interactively.
This commit is contained in:
parent
98788bf976
commit
65af18d86e
2 changed files with 27 additions and 16 deletions
|
@ -261,7 +261,7 @@ find a search tool; by default, this uses \"find | grep\" in the
|
||||||
`project-current' roots."
|
`project-current' roots."
|
||||||
(cl-mapcan
|
(cl-mapcan
|
||||||
(lambda (dir)
|
(lambda (dir)
|
||||||
(xref-collect-references identifier dir))
|
(xref-references-in-directory identifier dir))
|
||||||
(let ((pr (project-current t)))
|
(let ((pr (project-current t)))
|
||||||
(append
|
(append
|
||||||
(project-roots pr)
|
(project-roots pr)
|
||||||
|
@ -1129,7 +1129,7 @@ and just use etags."
|
||||||
(declare-function grep-expand-template "grep")
|
(declare-function grep-expand-template "grep")
|
||||||
(defvar ede-minor-mode) ;; ede.el
|
(defvar ede-minor-mode) ;; ede.el
|
||||||
|
|
||||||
(defun xref-collect-references (symbol dir)
|
(defun xref-references-in-directory (symbol dir)
|
||||||
"Find all references to SYMBOL in directory DIR.
|
"Find all references to SYMBOL in directory DIR.
|
||||||
Return a list of xref values.
|
Return a list of xref values.
|
||||||
|
|
||||||
|
@ -1160,8 +1160,13 @@ and when."
|
||||||
(xref--convert-hits (semantic-symref-perform-search inst)
|
(xref--convert-hits (semantic-symref-perform-search inst)
|
||||||
(format "\\_<%s\\_>" (regexp-quote symbol)))))
|
(format "\\_<%s\\_>" (regexp-quote symbol)))))
|
||||||
|
|
||||||
|
(define-obsolete-function-alias
|
||||||
|
'xref-collect-references
|
||||||
|
#'xref-references-in-directory
|
||||||
|
"27.1")
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun xref-collect-matches (regexp files dir ignores)
|
(defun xref-matches-in-directory (regexp files dir ignores)
|
||||||
"Find all matches for REGEXP in directory DIR.
|
"Find all matches for REGEXP in directory DIR.
|
||||||
Return a list of xref values.
|
Return a list of xref values.
|
||||||
Only files matching some of FILES and none of IGNORES are searched.
|
Only files matching some of FILES and none of IGNORES are searched.
|
||||||
|
@ -1207,6 +1212,11 @@ IGNORES is a list of glob patterns for files to ignore."
|
||||||
hits)))
|
hits)))
|
||||||
(xref--convert-hits (nreverse hits) regexp)))
|
(xref--convert-hits (nreverse hits) regexp)))
|
||||||
|
|
||||||
|
(define-obsolete-function-alias
|
||||||
|
'xref-collect-matches
|
||||||
|
#'xref-matches-in-directory
|
||||||
|
"27.1")
|
||||||
|
|
||||||
(defun xref--rgrep-command (regexp files dir ignores)
|
(defun xref--rgrep-command (regexp files dir ignores)
|
||||||
(require 'find-dired) ; for `find-name-arg'
|
(require 'find-dired) ; for `find-name-arg'
|
||||||
(defvar grep-find-template)
|
(defvar grep-find-template)
|
||||||
|
|
|
@ -27,14 +27,15 @@
|
||||||
(require 'cl-lib)
|
(require 'cl-lib)
|
||||||
|
|
||||||
(defvar xref-tests-data-dir
|
(defvar xref-tests-data-dir
|
||||||
(expand-file-name "data/xref/"
|
(expand-file-name "../../../data/xref/"
|
||||||
(getenv "EMACS_TEST_DIRECTORY")))
|
(or load-file-name
|
||||||
|
buffer-file-name)))
|
||||||
|
|
||||||
(ert-deftest xref-collect-matches-finds-none-for-some-regexp ()
|
(ert-deftest xref-matches-in-directory-finds-none-for-some-regexp ()
|
||||||
(should (null (xref-collect-matches "zzz" "*" xref-tests-data-dir nil))))
|
(should (null (xref-matches-in-directory "zzz" "*" xref-tests-data-dir nil))))
|
||||||
|
|
||||||
(ert-deftest xref-collect-matches-finds-some-for-bar ()
|
(ert-deftest xref-matches-in-directory-finds-some-for-bar ()
|
||||||
(let* ((matches (xref-collect-matches "bar" "*" xref-tests-data-dir nil))
|
(let* ((matches (xref-matches-in-directory "bar" "*" xref-tests-data-dir nil))
|
||||||
(locs (cl-sort (mapcar #'xref-item-location matches)
|
(locs (cl-sort (mapcar #'xref-item-location matches)
|
||||||
#'string<
|
#'string<
|
||||||
:key #'xref-location-group)))
|
:key #'xref-location-group)))
|
||||||
|
@ -42,8 +43,8 @@
|
||||||
(should (string-match-p "file1\\.txt\\'" (xref-location-group (nth 0 locs))))
|
(should (string-match-p "file1\\.txt\\'" (xref-location-group (nth 0 locs))))
|
||||||
(should (string-match-p "file2\\.txt\\'" (xref-location-group (nth 1 locs))))))
|
(should (string-match-p "file2\\.txt\\'" (xref-location-group (nth 1 locs))))))
|
||||||
|
|
||||||
(ert-deftest xref-collect-matches-finds-two-matches-on-the-same-line ()
|
(ert-deftest xref-matches-in-directory-finds-two-matches-on-the-same-line ()
|
||||||
(let* ((matches (xref-collect-matches "foo" "*" xref-tests-data-dir nil))
|
(let* ((matches (xref-matches-in-directory "foo" "*" xref-tests-data-dir nil))
|
||||||
(locs (mapcar #'xref-item-location matches)))
|
(locs (mapcar #'xref-item-location matches)))
|
||||||
(should (= 2 (length matches)))
|
(should (= 2 (length matches)))
|
||||||
(should (string-match-p "file1\\.txt\\'" (xref-location-group (nth 0 locs))))
|
(should (string-match-p "file1\\.txt\\'" (xref-location-group (nth 0 locs))))
|
||||||
|
@ -53,8 +54,8 @@
|
||||||
(should (equal 0 (xref-file-location-column (nth 0 locs))))
|
(should (equal 0 (xref-file-location-column (nth 0 locs))))
|
||||||
(should (equal 4 (xref-file-location-column (nth 1 locs))))))
|
(should (equal 4 (xref-file-location-column (nth 1 locs))))))
|
||||||
|
|
||||||
(ert-deftest xref-collect-matches-finds-an-empty-line-regexp-match ()
|
(ert-deftest xref-matches-in-directory-finds-an-empty-line-regexp-match ()
|
||||||
(let* ((matches (xref-collect-matches "^$" "*" xref-tests-data-dir nil))
|
(let* ((matches (xref-matches-in-directory "^$" "*" xref-tests-data-dir nil))
|
||||||
(locs (mapcar #'xref-item-location matches)))
|
(locs (mapcar #'xref-item-location matches)))
|
||||||
(should (= 1 (length matches)))
|
(should (= 1 (length matches)))
|
||||||
(should (string-match-p "file2\\.txt\\'" (xref-location-group (nth 0 locs))))
|
(should (string-match-p "file2\\.txt\\'" (xref-location-group (nth 0 locs))))
|
||||||
|
@ -62,7 +63,7 @@
|
||||||
(should (equal 0 (xref-file-location-column (nth 0 locs))))))
|
(should (equal 0 (xref-file-location-column (nth 0 locs))))))
|
||||||
|
|
||||||
(ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-1 ()
|
(ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-1 ()
|
||||||
(let* ((xrefs (xref-collect-matches "foo" "*" xref-tests-data-dir nil))
|
(let* ((xrefs (xref-matches-in-directory "foo" "*" xref-tests-data-dir nil))
|
||||||
(iter (xref--buf-pairs-iterator xrefs))
|
(iter (xref--buf-pairs-iterator xrefs))
|
||||||
(cons (funcall iter :next)))
|
(cons (funcall iter :next)))
|
||||||
(should (null (funcall iter :next)))
|
(should (null (funcall iter :next)))
|
||||||
|
@ -70,7 +71,7 @@
|
||||||
(should (= 2 (length (cdr cons))))))
|
(should (= 2 (length (cdr cons))))))
|
||||||
|
|
||||||
(ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-2 ()
|
(ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-2 ()
|
||||||
(let* ((xrefs (xref-collect-matches "bar" "*" xref-tests-data-dir nil))
|
(let* ((xrefs (xref-matches-in-directory "bar" "*" xref-tests-data-dir nil))
|
||||||
(iter (xref--buf-pairs-iterator xrefs))
|
(iter (xref--buf-pairs-iterator xrefs))
|
||||||
(cons1 (funcall iter :next))
|
(cons1 (funcall iter :next))
|
||||||
(cons2 (funcall iter :next)))
|
(cons2 (funcall iter :next)))
|
||||||
|
@ -80,7 +81,7 @@
|
||||||
(should (= 1 (length (cdr cons2))))))
|
(should (= 1 (length (cdr cons2))))))
|
||||||
|
|
||||||
(ert-deftest xref--buf-pairs-iterator-cleans-up-markers ()
|
(ert-deftest xref--buf-pairs-iterator-cleans-up-markers ()
|
||||||
(let* ((xrefs (xref-collect-matches "bar" "*" xref-tests-data-dir nil))
|
(let* ((xrefs (xref-matches-in-directory "bar" "*" xref-tests-data-dir nil))
|
||||||
(iter (xref--buf-pairs-iterator xrefs))
|
(iter (xref--buf-pairs-iterator xrefs))
|
||||||
(cons1 (funcall iter :next))
|
(cons1 (funcall iter :next))
|
||||||
(cons2 (funcall iter :next)))
|
(cons2 (funcall iter :next)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue