Function: eglot--flymake-handle-push

eglot--flymake-handle-push is a byte-compiled function defined in eglot.el.gz.

Signature

(eglot--flymake-handle-push SERVER URI DIAGNOSTICS VERSION THEN)

Documentation

Handle a diagnostics "push" from SERVER for document URI.

DIAGNOSTICS is a list of LSP diagnostic objects. VERSION is the LSP-reported version comparable to eglot--docver for which these objects presumably pertain. If diagnostics are thought to belong to eglot--docver THEN is a unary function taking DIAGNOSTICS and tasked to eventually report the corresponding Flymake conversions of each object. The originator of this "push" is usually either regular textDocument/publishDiagnostics or an experimental
$/streamDiagnostics notification.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/eglot.el.gz
(cl-defun eglot--flymake-handle-push (server uri diagnostics version then)
  "Handle a diagnostics \"push\" from SERVER for document URI.
DIAGNOSTICS is a list of LSP diagnostic objects.  VERSION is the
LSP-reported version comparable to `eglot--docver' for which these
objects presumably pertain.  If diagnostics are thought to belong to
`eglot--docver' THEN is a unary function taking DIAGNOSTICS and tasked
to eventually report the corresponding Flymake conversions of each
object.  The originator of this \"push\" is usually either regular
`textDocument/publishDiagnostics' or an experimental
`$/streamDiagnostics' notification."
  (if-let* ((path (expand-file-name (eglot-uri-to-path uri)))
            (buffer (eglot--find-buffer-visiting server path)))
      (with-current-buffer buffer
        (if (and version (/= version eglot--docver))
            (cl-return-from eglot--flymake-handle-push))
        ;; if no explicit version received, assume it's current.
        (setq version eglot--docver)
        (funcall then diagnostics))
    (cl-loop
     for diag-spec across diagnostics
     collect (eglot--dbind ((Diagnostic) code range message severity source) diag-spec
               (let* ((start (plist-get range :start))
                      (line (1+ (plist-get start :line)))
                      (char (1+ (plist-get start :character))))
                 (flymake-make-diagnostic
                  path (cons line char) nil
                  (eglot--flymake-diag-type severity)
                  (list source code message)
                  `((eglot-lsp-diag . ,diag-spec)))))
     into diags
     finally
     (setf (alist-get (propertize path 'eglot--server server)
                      flymake-list-only-diagnostics nil nil #'equal)
           diags))))