Function: bazel--xref-location

bazel--xref-location is a natively compiled function defined in bazel.el.

Signature

(bazel--xref-location FILENAME FIND-FUNCTION)

Documentation

Return an ‘xref-location’ for some entity within FILENAME.

FIND-FUNCTION should be a function taking zero arguments. This function calls FIND-FUNCTION in some buffer containing the contents of FILENAME. FIND-FUNCTION should then either return nil (if the entity isn’t found) or the position of the entity within the current buffer. FIND-FUNCTION should not move point or change the buffer state permanently.

Source Code

;; Defined in /nix/store/ws8pkszjvcad1rgzqw6wja7qxacylfhn-emacs-packages-deps/share/emacs/site-lisp/elpa/bazel-20261002.1510/bazel.el
(defun bazel--xref-location (filename find-function)
  "Return an ‘xref-location’ for some entity within FILENAME.
FIND-FUNCTION should be a function taking zero arguments.  This
function calls FIND-FUNCTION in some buffer containing the
contents of FILENAME.  FIND-FUNCTION should then either return
nil (if the entity isn’t found) or the position of the entity
within the current buffer.  FIND-FUNCTION should not move point
or change the buffer state permanently."
  (declare (ftype (function (string (function () (or null integer)))
                            xref-location)))
  (cl-check-type filename string)
  (cl-check-type find-function function)
  ;; Prefer a buffer that already visits FILENAME.
  (bazel--with-file-buffer existing filename
    (let ((found (funcall find-function)))
      (if existing
          ;; If not found, use point to avoid jumping around in the buffer.
          (xref-make-buffer-location (current-buffer) (or found (point)))
        (goto-char (or found (point-min)))
        (xref-make-file-location filename
                                 (line-number-at-pos)
                                 (- (point) (line-beginning-position)))))))