[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 4c5d0d4 53/69: Misc improvements to the xref glue
From: |
João Távora |
Subject: |
[elpa] externals/eglot 4c5d0d4 53/69: Misc improvements to the xref glue code |
Date: |
Sun, 20 Oct 2019 08:21:52 -0400 (EDT) |
branch: externals/eglot
commit 4c5d0d491532cd907beae12df5c2f01cd0290a7b
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Misc improvements to the xref glue code
* eglot.el (eglot-xref-backend): Don't check capability here.
(eglot--collecting-xrefs): Reworked from eglot--handling-xrefs.
(eglot--handling-xrefs): Remove.
(xref-backend-apropos, eglot--lsp-xrefs-for-method): Use
eglot--collecting-xrefs.
---
eglot.el | 37 +++++++++++++++++++++----------------
1 file changed, 21 insertions(+), 16 deletions(-)
diff --git a/eglot.el b/eglot.el
index 51914d9..9d5c546 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1714,9 +1714,7 @@ Calls REPORT-FN maybe if server publishes diagnostics in
time."
(funcall report-fn (cdr eglot--unreported-diagnostics))
(setq eglot--unreported-diagnostics nil)))
-(defun eglot-xref-backend ()
- "EGLOT xref backend."
- (when (eglot--server-capable :definitionProvider) 'eglot))
+(defun eglot-xref-backend () "EGLOT xref backend." 'eglot)
(defvar eglot--temp-location-buffers (make-hash-table :test #'equal)
"Helper variable for `eglot--handling-xrefs'.")
@@ -1724,12 +1722,16 @@ Calls REPORT-FN maybe if server publishes diagnostics
in time."
(defvar eglot-xref-lessp-function #'ignore
"Compare two `xref-item' objects for sorting.")
-(defmacro eglot--handling-xrefs (&rest body)
- "Properly sort and handle xrefs produced and returned by BODY."
- `(unwind-protect
- (sort (progn ,@body) eglot-xref-lessp-function)
- (maphash (lambda (_uri buf) (kill-buffer buf))
eglot--temp-location-buffers)
- (clrhash eglot--temp-location-buffers)))
+(cl-defmacro eglot--collecting-xrefs ((collector) &rest body)
+ "Sort and handle xrefs collected with COLLECTOR in BODY."
+ (let ((collected (cl-gensym "collected")))
+ `(unwind-protect
+ (let (,collected)
+ (cl-flet ((,collector (xref) (push xref ,collected)))
+ ,@body)
+ (sort ,collected eglot-xref-lessp-function))
+ (maphash (lambda (_uri buf) (kill-buffer buf))
eglot--temp-location-buffers)
+ (clrhash eglot--temp-location-buffers))))
(defun eglot--xref-make (name uri range)
"Like `xref-make' but with LSP's NAME, URI and RANGE.
@@ -1783,8 +1785,8 @@ Try to visit the target file for a richer summary line."
(cadr (split-string (symbol-name method)
"/"))))))
(eglot--error "Sorry, this server doesn't do %s" method))
- (eglot--handling-xrefs
- (mapcar
+ (eglot--collecting-xrefs (collect)
+ (mapc
(eglot--lambda ((Location) uri range)
(eglot--xref-make (symbol-at-point) uri range))
(jsonrpc-request
@@ -1792,9 +1794,12 @@ Try to visit the target file for a richer summary line."
(eglot--TextDocumentPositionParams)
extra-params)))))
-(defun eglot--lsp-xref-helper (method)
+(cl-defun eglot--lsp-xref-helper (method &key extra-params capability )
"Helper for `eglot-find-declaration' & friends."
- (let ((eglot--lsp-xref-refs (eglot--lsp-xrefs-for-method method)))
+ (let ((eglot--lsp-xref-refs (eglot--lsp-xrefs-for-method
+ method
+ :extra-params extra-params
+ :capability capability)))
(xref-find-references "LSP identifier at point.")))
(defun eglot-find-declaration ()
@@ -1823,11 +1828,11 @@ Try to visit the target file for a richer summary line."
(cl-defmethod xref-backend-apropos ((_backend (eql eglot)) pattern)
(when (eglot--server-capable :workspaceSymbolProvider)
- (eglot--handling-xrefs
- (mapcar
+ (eglot--collecting-xrefs (collect)
+ (mapc
(eglot--lambda ((SymbolInformation) name location)
(eglot--dbind ((Location) uri range) location
- (eglot--xref-make name uri range)))
+ (collect (eglot--xref-make name uri range))))
(jsonrpc-request (eglot--current-server-or-lose)
:workspace/symbol
`(:query ,pattern))))))
- [elpa] externals/eglot a11a41b 63/69: Use of company-capf backend in eglot-managed buffers, (continued)
- [elpa] externals/eglot a11a41b 63/69: Use of company-capf backend in eglot-managed buffers, João Távora, 2019/10/20
- [elpa] externals/eglot 6e93622 27/69: Fix #273: leniently handle invalid positions sent by some servers, João Távora, 2019/10/20
- [elpa] externals/eglot 254fee0 46/69: Use more pyls and less rls in tests, João Távora, 2019/10/20
- [elpa] externals/eglot 0e5e08d 51/69: Support goto-{declaration, implementation, typeDefinition}, João Távora, 2019/10/20
- [elpa] externals/eglot 5a21670 59/69: Fix bug in workspace/didChangeWatchedfiles, João Távora, 2019/10/20
- [elpa] externals/eglot 9359c15 58/69: Close #316: add support for the Ada Language Server, João Távora, 2019/10/20
- [elpa] externals/eglot d6508e0 29/69: Fix #273: fix a typo, João Távora, 2019/10/20
- [elpa] externals/eglot 28ecd5d 34/69: Change the default of eglot-move-to-column-function, João Távora, 2019/10/20
- [elpa] externals/eglot 7a70c97 33/69: Require array package to use current-line (#294), João Távora, 2019/10/20
- [elpa] externals/eglot f7a1bf6 49/69: Fix #236: much less noisy mode line, João Távora, 2019/10/20
- [elpa] externals/eglot 4c5d0d4 53/69: Misc improvements to the xref glue code,
João Távora <=
- [elpa] externals/eglot 5ea4049 68/69: Fix #324: let user keep control of some variables during Eglot sessions, João Távora, 2019/10/20
- [elpa] externals/eglot 33a4f86 69/69: * eglot.el (Version): Bump to 1.5, João Távora, 2019/10/20
- [elpa] externals/eglot cf161b0 41/69: Test with emacs master on Travis, João Távora, 2019/10/20
- [elpa] externals/eglot 9e70cd2 40/69: * eglot-tests.el (python-autopep-formatting): Attempt to fix test., João Távora, 2019/10/20
- [elpa] externals/eglot c3bae0a 44/69: New test for the eglot-autoshutdown defcustom, João Távora, 2019/10/20
- [elpa] externals/eglot 28d8ffe 48/69: Fix #285: unbreak Elm language server which does use :triggerCharacters, João Távora, 2019/10/20
- [elpa] externals/eglot 06ff65d 52/69: Rework and correct major part of xref glue code, João Távora, 2019/10/20
- [elpa] externals/eglot 9951dc5 62/69: Add a test for vscode-json-languageserver's completions, João Távora, 2019/10/20
- [elpa] externals/eglot 124a833 56/69: Add a test for #311 and #279, João Távora, 2019/10/20
- [elpa] externals/eglot d774754 37/69: Merge pull request #298 from jorams/nil-capabilities-as-false, João Távora, 2019/10/20