|
1 | 1 | ;;; cider-client.el --- A layer of abstraction above low-level nREPL client code. -*- lexical-binding: t -*-
|
2 | 2 |
|
3 |
| -;; Copyright © 2013-2024 Bozhidar Batsov |
| 3 | +;; Copyright © 2013-2025 Bozhidar Batsov |
4 | 4 | ;;
|
5 | 5 | ;; Author: Bozhidar Batsov <[email protected]>
|
6 | 6 |
|
@@ -189,16 +189,20 @@ the current connection. Return the id of the sent message.
|
189 | 189 | If TOOLING is truthy then the tooling session is used."
|
190 | 190 | (nrepl-send-request request callback (or connection (cider-current-repl 'any 'ensure)) tooling))
|
191 | 191 |
|
192 |
| -(defun cider-nrepl-send-sync-request (request &optional connection abort-on-input) |
| 192 | +(defun cider-nrepl-send-sync-request (request &optional connection |
| 193 | + abort-on-input callback) |
193 | 194 | "Send REQUEST to the nREPL server synchronously using CONNECTION.
|
194 | 195 | Hold till final \"done\" message has arrived and join all response messages
|
195 | 196 | of the same \"op\" that came along and return the accumulated response.
|
196 | 197 | If ABORT-ON-INPUT is non-nil, the function will return nil
|
197 | 198 | at the first sign of user input, so as not to hang the
|
198 |
| -interface." |
| 199 | +interface. |
| 200 | +if CALLBACK is non-nil, it will additionally be called on all received messages." |
199 | 201 | (nrepl-send-sync-request request
|
200 | 202 | (or connection (cider-current-repl 'any 'ensure))
|
201 |
| - abort-on-input)) |
| 203 | + abort-on-input |
| 204 | + nil |
| 205 | + callback)) |
202 | 206 |
|
203 | 207 | (defun cider-nrepl-send-unhandled-request (request &optional connection)
|
204 | 208 | "Send REQUEST to the nREPL CONNECTION and ignore any responses.
|
@@ -342,6 +346,17 @@ The default value in nREPL is 1024."
|
342 | 346 | :group 'cider
|
343 | 347 | :package-version '(cider . "0.25.0"))
|
344 | 348 |
|
| 349 | +(defcustom cider-download-java-sources nil |
| 350 | + "Whether to automatically download source artifacts for 3rd-party Java classes. |
| 351 | +
|
| 352 | +When enabled, CIDER will attempt to download source JARs from Maven for |
| 353 | +Java classes if the source file is not found locally. This downloading only |
| 354 | +happens once per artifact, and only when the user jumps to definition or |
| 355 | +requests `cider-doc' on a Java class or a member of the class." |
| 356 | + :type 'boolean |
| 357 | + :group 'cider |
| 358 | + :package-version '(cider . "1.17.0")) |
| 359 | + |
345 | 360 | (defun cider--print-fn ()
|
346 | 361 | "Return the value to send in the nrepl.middleware.print/print slot."
|
347 | 362 | (pcase cider-print-fn
|
@@ -681,13 +696,25 @@ CONTEXT represents a completion context for compliment."
|
681 | 696 |
|
682 | 697 | (defun cider-sync-request:info (symbol &optional class member context)
|
683 | 698 | "Send \"info\" op with parameters SYMBOL or CLASS and MEMBER, honor CONTEXT."
|
684 |
| - (let ((var-info (thread-first `("op" "info" |
685 |
| - "ns" ,(cider-current-ns) |
686 |
| - ,@(when symbol `("sym" ,symbol)) |
687 |
| - ,@(when class `("class" ,class)) |
688 |
| - ,@(when member `("member" ,member)) |
689 |
| - ,@(when context `("context" ,context))) |
690 |
| - (cider-nrepl-send-sync-request (cider-current-repl))))) |
| 699 | + (let* ((req |
| 700 | + `("op" "info" |
| 701 | + "ns" ,(cider-current-ns) |
| 702 | + ,@(when symbol `("sym" ,symbol)) |
| 703 | + ,@(when class `("class" ,class)) |
| 704 | + ,@(when member `("member" ,member)) |
| 705 | + ,@(when context `("context" ,context)) |
| 706 | + ,@(when cider-download-java-sources `("download-sources-jar" "1")))) |
| 707 | + (callback |
| 708 | + (lambda (resp) |
| 709 | + (let ((status (nrepl-dict-get resp "status")) |
| 710 | + (coords (nrepl-dict-get resp "coords"))) |
| 711 | + (when (member "download-sources-jar" status) |
| 712 | + (message "Local source not found, downloading Java sources for artifact %s/%s %s..." |
| 713 | + (nrepl-dict-get coords "group") |
| 714 | + (nrepl-dict-get coords "artifact") |
| 715 | + (nrepl-dict-get coords "version")))))) |
| 716 | + (var-info |
| 717 | + (cider-nrepl-send-sync-request req (cider-current-repl) nil callback))) |
691 | 718 | (if (member "no-info" (nrepl-dict-get var-info "status"))
|
692 | 719 | nil
|
693 | 720 | var-info)))
|
|
0 commit comments