Function: eglot--lsp-xrefs-for-id
eglot--lsp-xrefs-for-id is a byte-compiled function defined in
eglot.el.gz.
Signature
(eglot--lsp-xrefs-for-id ID METHOD &key JUST-DEF EXTRA-ARGS)
Documentation
Make xref's for ID and METHOD.
Check first if ID is enriched from a previous workspace/symbol request
. If so we can craft the LSP request to collect xrefs from that
location's URI and RANGE or, if JUST-DEF is non-nil, immediately return
a list of a single xref that is that location without bothering the
server at all. Otherwise, make the request for the thing at point.
EXTRA-ARGS are added to the request.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/eglot.el.gz
(cl-defun eglot--lsp-xrefs-for-id (id method &key just-def extra-args)
"Make `xref''s for ID and METHOD.
Check first if ID is enriched from a previous `workspace/symbol' request
. If so we can craft the LSP request to collect xrefs from that
location's URI and RANGE or, if JUST-DEF is non-nil, immediately return
a list of a single xref that is that location without bothering the
server at all. Otherwise, make the request for the thing at point.
EXTRA-ARGS are added to the request."
(cl-flet ((make-xrefs (position-params name)
(eglot-server-capable-or-lose
(intern
(format ":%sProvider"
(cadr (split-string (symbol-name method)
"/")))))
(let ((response
(eglot--request
(eglot--current-server-or-lose)
method (append position-params extra-args))))
(eglot--collecting-xrefs (collect)
(mapc
(lambda (loc-or-loc-link)
(eglot--dcase loc-or-loc-link
(((LocationLink) targetUri targetSelectionRange)
(collect (eglot--xref-make-match name
targetUri targetSelectionRange)))
(((Location) uri range)
(collect (eglot--xref-make-match name
uri range)))))
(if (vectorp response) response
(and response (list response))))))))
(if-let* ((probe (eglot--recover-workspace-symbol-meta id)))
(eglot--dbind ((WorkspaceSymbol) name location)
(get-text-property 0 'eglot--lsp-workspaceSymbol probe)
(eglot--dbind ((Location) uri range) location
(if just-def
(list (eglot--xref-make-match name uri range))
;; JT@2026-09-05: clangd will fail the uri isn't already
;; managed. This is a server bug. See commit message.
(make-xrefs
(list :textDocument (list :uri uri)
:position (cl-getf range :start))
name))))
(make-xrefs (eglot--TextDocumentPositionParams)
(symbol-name (symbol-at-point))))))