Function: dape--set-breakpoints-in-source
dape--set-breakpoints-in-source is a natively compiled function
defined in dape.el.
Signature
(dape--set-breakpoints-in-source CONN SOURCE &optional CB)
Documentation
Set breakpoints in SOURCE for adapter CONN.
SOURCE is expected to be buffer or file name string.
See dape-request for expected CB signature.
Source Code
;; Defined in /nix/store/1fiaif8pifqj2jh65rbg3fkhg3i56q42-emacs-packages-deps/share/emacs/site-lisp/elpa/dape-0.27.1/dape.el
(defun dape--set-breakpoints-in-source (conn source &optional cb)
"Set breakpoints in SOURCE for adapter CONN.
SOURCE is expected to be buffer or file name string.
See `dape-request' for expected CB signature."
(cl-flet
((objectify (breakpoint)
(let ((plist `(:line ,(dape--breakpoint-line breakpoint))))
(pcase (dape--source-breakpoint-type breakpoint)
('log
(if (dape--capable-p conn :supportsLogPoints)
(plist-put plist :logMessage
(dape--source-breakpoint-value breakpoint))
(dape--warn "Adapter does not support `dape-breakpoint-log'")))
('expression
(if (dape--capable-p conn :supportsConditionalBreakpoints)
(plist-put plist :condition
(dape--source-breakpoint-value breakpoint))
(dape--warn
"Adapter does not support `dape-breakpoint-expression'")))
('hits
(if (dape--capable-p conn :supportsHitConditionalBreakpoints)
(plist-put plist :hitCondition
(dape--source-breakpoint-value breakpoint))
(dape--warn
"Adapter does not support `dape-breakpoint-hits'"))))
plist)))
(let ((;; Importantly `breakpoints' is not the same object as
;; `dape--breakpoints' otherwise we would get hurt by
;; mutations while request-in-flight.
breakpoints
(cl-loop for b in dape--breakpoints
when (and (dape--source-breakpoint-p b)
(equal (dape--breakpoint-source b) source)
(not (dape--breakpoint-disabled b)))
collect b))
(source-object
(pcase source
((pred stringp) `(:path ,(dape--file-name-remote conn source)))
((pred bufferp)
(or
;; Is source buffer (see `dape--source-make-buffer')?
(cl-loop with buffers = (dape--source-buffers (dape--root-of conn))
for (reference buffer) on buffers by #'cddr
when (eq buffer source)
return `(:sourceReference ,reference))
;; Other buffer?
(when-let* ((filename (dape--file-name-remote
conn (buffer-file-name source))))
`(:path ,filename)))))))
(if (not source-object)
(dape--request-continue cb)
(dape--with-request-bind
((&key ((:breakpoints updates)) &allow-other-keys) error)
(dape-request
conn :setBreakpoints
`( :breakpoints ,(cl-map 'vector #'objectify breakpoints)
:lines ,(cl-map 'vector #'dape--breakpoint-line breakpoints)
:source ,source-object))
(if error
(dape--warn "Failed to set breakpoints in %s; %s" source error)
(cl-loop for breakpoint in breakpoints
for update across updates
do (dape--breakpoint-update conn breakpoint update))
(dape--request-continue cb error)))))))