Function: bazel--target-location
bazel--target-location is a natively compiled function defined in
bazel.el.
Signature
(bazel--target-location REPOSITORY PACKAGE TARGET)
Documentation
Return an ‘xref-location’ for a Bazel target.
The target is in the repository with root directory REPOSITORY and the package PACKAGE. Its local name is TARGET. If no target was found, return nil. This function uses heuristics to find the target; in particular, it assumes that a target that looks like a valid file target is indeed a file target.
Source Code
;; Defined in /nix/store/ws8pkszjvcad1rgzqw6wja7qxacylfhn-emacs-packages-deps/share/emacs/site-lisp/elpa/bazel-20261002.1510/bazel.el
(defun bazel--target-location (repository package target)
"Return an ‘xref-location’ for a Bazel target.
The target is in the repository with root directory REPOSITORY
and the package PACKAGE. Its local name is TARGET. If no target
was found, return nil. This function uses heuristics to find the
target; in particular, it assumes that a target that looks like a
valid file target is indeed a file target."
(declare (ftype (function (string string string) (or xref-location null))))
(cl-check-type repository string)
(cl-check-type package string)
(cl-check-type target string)
(let* ((directory (expand-file-name package repository))
(filename (expand-file-name target directory)))
(if (file-exists-p filename)
;; A label that likely refers to a source file.
(bazel--file-location filename)
;; A label that likely refers to a rule target. Try to find the target
;; definition in the BUILD file of the package.
(when-let* ((build-file (bazel--locate-build-file directory)))
(bazel--rule-target-location build-file target)))))