Hint to load the namespace on unresolved-var failures#3974
Closed
bbatsov wants to merge 1 commit into
Closed
Conversation
Extract a shared `cider-ensure-var-resolved' gate that, when a var can't be resolved, points the user at `cider-load-buffer' - by far the most common cause is that the var's namespace simply hasn't been loaded into the REPL yet. This generalizes the graceful hint that macroexpansion already grew in 1.22, de-duplicating it out of the two macro helpers and extending it to `cider-find-var' and `cider-doc', which previously failed with a cryptic "Symbol not resolved".
Member
Author
|
Going to close this in favor of #3979, which takes the same approach further: it tells a genuinely unloaded namespace apart from a typo, a missing require, or an out-of-sync var, works without cider-nrepl, and extends the hints to ClojureDocs, xref and browse-ns as well. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Where #3973 shows the namespace load state, this makes the failure modes graceful: when you act on a var whose namespace isn't loaded, you get told what to do instead of a cryptic dead end.
#3972 taught the macroexpansion commands to say "its namespace may not be loaded; try
C-c C-k" instead of silently doing nothing. This generalizes that:cider-ensure-var-resolvedgate (next tocider-ensure-connected/cider-ensure-op-supported).cider-macrostepandcider-macroexpansion) - pure refactor, same behavior.cider-find-varandcider-doc, which previously failed with the unhelpful "Symbol not resolved".The message points at
cider-load-bufferviasubstitute-command-keys, so it shows whatever key it's actually bound to.Scoped to the "ensure loaded" half. The "in sync / stale" detection lives in #3973; a later iteration could have this gate consult that state too, but keeping them independent makes each easier to review. The gate can easily be pushed into more call sites (eldoc, inspect, etc.) too.