Function: bazel-completion-at-point

bazel-completion-at-point is a natively compiled function defined in bazel.el.

Signature

(bazel-completion-at-point)

Documentation

Provide completion of Bazel target labels at point.

‘bazel-mode’ adds this function to
‘completion-at-point-functions’.
See Info node (elisp) Completion in Buffers for context.

Source Code

;; Defined in /nix/store/ws8pkszjvcad1rgzqw6wja7qxacylfhn-emacs-packages-deps/share/emacs/site-lisp/elpa/bazel-20261002.1510/bazel.el
;;;; Completion support

(defun bazel-completion-at-point ()
  "Provide completion of Bazel target labels at point.
‘bazel-mode’ adds this function to
‘completion-at-point-functions’.
See Info node ‘(elisp) Completion in Buffers’ for context."
  (declare (ftype (function () list)))
  ;; This function should be fast, so we perform the quick checks (reading
  ;; variables, syntax tables) first before hitting the filesystem to find the
  ;; repository root.
  (when-let* ((file-name buffer-file-name))
    (when (derived-mode-p 'bazel-mode)
      ;; We assume for now that labels always appear as strings.  That should
      ;; cover most cases (e.g. “deps” attributes), but not add large amounts of
      ;; false positives.
      (let ((state (syntax-ppss)))
        (when (ppss-string-terminator state) ; in string
          (let ((start (1+ (ppss-comment-or-string-start state))))
            (save-excursion
              ;; Jump to the closing quotation mark.
              (parse-partial-sexp (point) (point-max) nil nil state
                                  'syntax-table)
              (let ((end (1- (point))))
                (when (>= end start)
                  (when-let* ((table (bazel--completion-at-point-table start)))
                    (list start end table)))))))))))