Function: eglot--check-object
eglot--check-object is a byte-compiled function defined in
eglot.el.gz.
Signature
(eglot--check-object INTERFACE-NAME OBJECT &optional (ENFORCE-REQUIRED t) (DISALLOW-NON-STANDARD t) (CHECK-TYPES t))
Documentation
Check that OBJECT conforms to INTERFACE. Error otherwise.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/eglot.el.gz
(cl-defun eglot--check-object (interface-name
object
&optional
(enforce-required t)
(disallow-non-standard t)
(check-types t))
"Check that OBJECT conforms to INTERFACE. Error otherwise."
(cl-destructuring-bind
(&key types required-keys optional-keys &allow-other-keys)
(eglot--interface interface-name)
(when-let* ((missing (and enforce-required
(cl-set-difference required-keys
(eglot--plist-keys object)))))
(eglot--error "A `%s' must have %s" interface-name missing))
(when-let* ((excess (and disallow-non-standard
(cl-set-difference
(eglot--plist-keys object)
(append required-keys optional-keys)))))
(eglot--error "A `%s' mustn't have %s" interface-name excess))
(when check-types
(cl-loop
for (k v) on object by #'cddr
for type = (or (cdr (assoc k types)) t) ;; FIXME: enforce nil type?
unless (cl-typep v type)
do (eglot--error "A `%s' must have a %s as %s, but has %s"
interface-name)))
t))