-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[info] Add support for automatically downloading sources JARs #911
Conversation
@@ -57,11 +57,9 @@ | |||
then had to be disabled for test suite reasons in Orchard 0.15.0 to 0.17.0 / cider-nrepl 0.38.0 to 0.41.0, and now it's restored again) | |||
Note that this can only be done cider-nrepl side, unlike before when it was done in Orchard itself." | |||
[] | |||
;; 1.- Warmup the overall cache for core Java and Clojure stuff | |||
@orchard.java/cache-initializer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This initializer was removed in latest Orchard.
*clojure-version* min-clojure-verion)] | ||
(try | ||
(.println System/err msg) | ||
(finally (throw (ex-info msg {})))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like that a library can System/exit, I think it takes too much upon itself. Throwing an exception is better because it can be caught (for whichever reason the user has), it can be properly logged, you get a stacktrace to know who required cider.nrepl
namespace (e.g. this might be a surprise to the user), etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine by me - that System/exit
was always controversial. Ideally we'd have at some point a way for the server to notify clients if they are not meeting some runtime requirements, but if cider-nrepl can work to some extent and the users are aware of this, it's probably a good trade-off.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify, if user doesn't try to catch the exception around requiring cider.nrepl
, then the end result will be the same as in System/exit – the server will fail to start. It's just that throwing an exception gives more options to react to it and properly report.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, yeah - I get this. My point was mainly that the way the code was previously written it would fail on the version check alone, even if it might actually work in practice and might be fine with some users. (working, but not really supported) I think the purpose of the explicit exit
here was to prevent such scenarios from happening.
I agree it's better for the clients to decide how to handle an error from a library that they're using.
56f4ba7
to
28d9332
Compare
28d9332
to
d609ab6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the failing tests the PR looks good to me.
You might want to mention this somewhere in the comments and perhaps later in CIDER's docs, so people are aware this is intentional. |
67fff19
to
3c7cb91
Compare
I'll mention it in the CIDER docs; there's probably not a place to mention it here because it is not controlled on cider-nrepl side. If the client decides to set the |
b83aa07
to
3e17faa
Compare
3e17faa
to
65a1c8a
Compare
Sister PRs: clojure-emacs/orchard#310, clojure-emacs/cider#3769.
Not a lot of changes were needed here. Given how things are implemented on the Orchard side, cider-nrepl only needs to set up a correct
*download-sources-jar-fn*
before calling out to Orchard functions that do Java sources discovery.We maintain a ConcurrentHashMap (logically, a set, but there is no ConcurrentHashSet, and CHM API for this usecase is cleaner than
(atom #{})
) of Maven coordinates (groupId/artifactId "version"
) of the dependencies we already tried downloading sources once. If it succeeded, we won't call this function again anyway, if it failed, the CHM will prevent trying for the second time. This debouncer only exists in memory which I suppose makes it easier to retry (by restarting) if the sources failed to download because bad Internet or something, not because the sources JAR does not exist in the repository. If this cache was persistent, retrying will be a bit more involved. Anyway, this may change after user feedback; maybe, there would be frequent annoying cases where certain Java classes wouldn't have sources JAR, and it will be annoying that the firstC-c C-d C-d
on such class is slow after each REPL restart.We bind
*download-sources-jar-fn*
only ininfo
op, not theeldoc
op. Eldoc is less intentional and much more common, so I don't want to make slow and download things. Counter to that,info
is invoked byM-.
orC-c C-d C-d
where the user explicitly requested something, so it makes sense to attempt downloading then. Until the JAR is downloaded,eldoc
will simply return results obtained via reflection, after that it will pick up the parsed Javadocs.