Function: bazel--target-completion-default

bazel--target-completion-default is a natively compiled function defined in bazel.el.

Signature

(bazel--target-completion-default SOURCE-FILE ROOT PACKAGE ONLY-TESTS)

Documentation

Return default completion target for SOURCE-FILE.

ROOT is the repository root directory, and PACKAGE is the package name. If ONLY-TESTS is non-nil, look only for test targets. Return nil if SOURCE-FILE is nil or no suitable default target was found.

Source Code

;; Defined in /nix/store/ws8pkszjvcad1rgzqw6wja7qxacylfhn-emacs-packages-deps/share/emacs/site-lisp/elpa/bazel-20261002.1510/bazel.el
(defun bazel--target-completion-default (source-file root package only-tests)
  "Return default completion target for SOURCE-FILE.
ROOT is the repository root directory, and PACKAGE is the package
name.  If ONLY-TESTS is non-nil, look only for test targets.
Return nil if SOURCE-FILE is nil or no suitable default target
was found."
  (declare (ftype (function ((or string null) string string t)
                            (or string null))))
  (cl-check-type source-file (or string null))
  (cl-check-type root string)
  (cl-check-type package string)
  (when source-file
    (let* ((directory (file-name-as-directory (expand-file-name package root)))
           (relative-file (file-relative-name source-file directory))
           (case-fold-file (file-name-case-insensitive-p source-file)))
      (when-let* ((build-file (bazel--locate-build-file directory))
                  (target (bazel--consuming-target build-file relative-file
                                                   case-fold-file only-tests)))
        (bazel--canonical nil package target)))))