Function: dape--inlay-hint-update-overlay-contents

dape--inlay-hint-update-overlay-contents is a natively compiled function defined in dape.el.

Signature

(dape--inlay-hint-update-overlay-contents SCOPES)

Documentation

Update overlay after-string variables in SCOPES.

This is a helper function for dape-inlay-hints-update.

Source Code

;; Defined in /nix/store/1fiaif8pifqj2jh65rbg3fkhg3i56q42-emacs-packages-deps/share/emacs/site-lisp/elpa/dape-0.27.1/dape.el
(defun dape--inlay-hint-update-overlay-contents (scopes)
  "Update overlay after-string variables in SCOPES.
This is a helper function for `dape-inlay-hints-update'."
  ;; 1. Update each overlay's symbol list with (NAME VALUE UPDATED-P)
  (cl-loop
   with all-symbols =
   (cl-loop for overlay in dape--inlay-hint-overlays
            when (overlayp overlay)
            append (overlay-get overlay 'dape-symbols))
   for scope in (reverse scopes) do
   (cl-loop for variable in (plist-get scope :variables)
            for value = (plist-get variable :value)
            for name = (plist-get variable :name) do
            (cl-loop for symbol-entry in all-symbols
                     for (hint-name previous-value) = symbol-entry
                     for updated-p = (and previous-value
                                          (not (equal previous-value value)))
                     when (equal name hint-name) do
                     (setcdr symbol-entry `(,value ,updated-p)))))
  ;; 2. Format and display the overlays after-string's
  (cl-loop
   for overlay in dape--inlay-hint-overlays
   when (overlayp overlay) do
   (cl-loop
    with symbols = (overlay-get overlay 'dape-symbols)
    for (symbol-name value updated-p) in symbols
    when value collect
    (concat
     ;; Variable name with interactive properties
     (propertize
      (format "%s :" symbol-name)
      'face 'dape-inlay-hint-face
      'mouse-face 'highlight
      'keymap
      (let ((keymap (make-sparse-keymap))
            (captured-symbol symbol-name))
        (define-key keymap [mouse-1]
                    (lambda ()
                      (interactive)
                      (dape-watch-dwim captured-symbol nil 'only-add 'display)))
        keymap)
      'help-echo
      (format "mouse-1: add `%s' to watch" symbol-name))
     " "
     ;; ..and value, truncating if necessary
     (propertize
      (truncate-string-to-width
       (substring value 0 (string-match-p "\n" value))
       dape-inlay-hints-variable-name-max nil nil t)
      'help-echo value
      'face (if updated-p
                'dape-inlay-hint-highlight-face
              'dape-inlay-hint-face)))
    into formatted-strings
    ;; Set after-string to display hint
    finally do
    (when formatted-strings
      (thread-last (mapconcat #'identity formatted-strings
                              dape--inlay-hint-seperator)
                   (format "  %s")
                   (overlay-put overlay 'after-string))))))