Function: bazel--target-completion-table-2
bazel--target-completion-table-2 is a natively compiled function
defined in bazel.el.
Signature
(bazel--target-completion-table-2 ROOT REPOSITORY PACKAGE PATTERN ONLY-TESTS COLON)
Documentation
Return a completion table for Bazel targets or target patterns.
ROOT is the main repository root, REPOSITORY is the external
repository name or the empty string for the main repository, and
PACKAGE is the package name within the repository. If PATTERN is
non-nil, complete target patterns, include target wildcards like
“:all”, and skip files. If ONLY-TESTS is non-nil, restrict rule
target completion to test targets. If COLON is non-nil, prefix
the wildcards with a colon. This is a helper function for
‘bazel--target-completion-table’.
Source Code
;; Defined in /nix/store/ws8pkszjvcad1rgzqw6wja7qxacylfhn-emacs-packages-deps/share/emacs/site-lisp/elpa/bazel-20261002.1510/bazel.el
(defun bazel--target-completion-table-2
(root repository package pattern only-tests colon)
"Return a completion table for Bazel targets or target patterns.
ROOT is the main repository root, REPOSITORY is the external
repository name or the empty string for the main repository, and
PACKAGE is the package name within the repository. If PATTERN is
non-nil, complete target patterns, include target wildcards like
“:all”, and skip files. If ONLY-TESTS is non-nil, restrict rule
target completion to test targets. If COLON is non-nil, prefix
the wildcards with a colon. This is a helper function for
‘bazel--target-completion-table’."
(declare (ftype (function (string string string t t t) t)))
(cl-check-type root string)
(cl-check-type repository string)
(cl-check-type package string)
(when-let* ((external-root (if (string-empty-p repository) root
(bazel--external-repository repository root)))
(build-file (bazel--locate-build-file
(expand-file-name package external-root))))
(let ((completion-regexp-list
(cons (rx bos (+ (any "a-z" "A-Z" "0-9" ?-
"!%@^_` \"#$&'()*+,;<=>?[]{|}~/."))
eos)
completion-regexp-list)))
(completion-table-merge
(completion-table-with-cache
(lambda (prefix)
(cl-check-type prefix string)
(append
(bazel--with-file-buffer existing build-file
;; ‘bazel--complete-targets’ only works in ‘bazel-mode’.
(unless existing (bazel-build-mode))
(bazel--complete-targets prefix only-tests))
(unless pattern
;; Include source files only if we’re not completing a target
;; pattern. Building a source file makes no sense.
(let ((default-directory (file-name-directory build-file)))
(bazel--complete-files prefix)))))
completion-ignore-case)
;; We only want to add the wildcards if this is indeed a package. Do
;; this here so that we don’t have to check twice.
(when pattern
(if colon
'(":all" ":all-targets" ":*")
'("all" "all-targets" "*")))))))