Function: bazel--diagnostic-for-warning
bazel--diagnostic-for-warning is a natively compiled function defined
in bazel.el.
Signature
(bazel--diagnostic-for-warning WARNING)
Documentation
Return a Flymake diagnostic for the Buildifier WARNING.
WARNING should be a hashtable containing a single warning, as
described in URL
‘https://github.com/bazelbuild/buildtools/blob/master/buildifier/README.md#file-diagnostics-in-json’.
Source Code
;; Defined in /nix/store/ws8pkszjvcad1rgzqw6wja7qxacylfhn-emacs-packages-deps/share/emacs/site-lisp/elpa/bazel-20261002.1510/bazel.el
(defun bazel--diagnostic-for-warning (warning)
"Return a Flymake diagnostic for the Buildifier WARNING.
WARNING should be a hashtable containing a single warning, as
described in URL
‘https://github.com/bazelbuild/buildtools/blob/master/buildifier/README.md#file-diagnostics-in-json’."
(declare (ftype (function (hash-table) t)))
(cl-check-type warning hash-table)
(let* ((case-fold-search nil)
(search-spaces-regexp nil)
(start (gethash "start" warning))
(end (gethash "end" warning))
;; Note: Both line and column are one-based in the Buildifier output.
(start-line (gethash "line" start))
(start-column (1- (gethash "column" start)))
(end-line (gethash "line" end))
(end-column (1- (gethash "column" end)))
(message (gethash "message" warning)))
(when (and (= start-line end-line) (= start-column 0) (= end-column 1))
;; Heuristic: assume this means the entire line. Buildifier emits this
;; e.g. for the module-docstring warning. ‘bazel--line-column-pos’
;; ensures that we don’t cross line boundaries.
(setq end-column (buffer-size)))
(flymake-make-diagnostic
(current-buffer)
(bazel--line-column-pos start-line start-column)
(bazel--line-column-pos end-line end-column)
:warning
(format-message "%s [%s] (%s)"
;; We only take the first line of the message, otherwise
;; it becomes too long and looks ugly.
(substring-no-properties message nil
(string-match-p (rx ?\n) message))
(gethash "category" warning)
(gethash "url" warning)))))