Skip to content

Add a command that adds the require or import a symbol needs - #4217

Merged
bbatsov merged 2 commits into
masterfrom
ns-add-missing
Oct 24, 2026
Merged

bbatsov merged 2 commits into
masterfrom
ns-add-missing

Conversation

@bbatsov

@bbatsov bbatsov commented Oct 20, 2026

Copy link
Copy Markdown
Member

This replaces cljr-add-missing-libspec, using the cider/resolve-missing op from clojure-emacs/cider-nrepl#1056. cider-ns-add-require now also adds a missing alias to a namespace that's already required, instead of reporting it as required. It builds on #4216, whose commit shows up here until that one merges.

@bbatsov
bbatsov force-pushed the ns-add-missing branch 3 times, most recently from 6765422 to 1f0aa9e Compare October 22, 2026 16:44
@bbatsov bbatsov mentioned this pull request Oct 23, 2026
clj-refactor's cljr-add-missing-libspec needs refactor-nrepl, and
cider-nrepl's new cider/resolve-missing op makes that unnecessary.
cider-ns-add-missing asks it what could provide the symbol at point and
adds the pick: a refer for foo, an alias for alias/foo, a plain require
for some.ns/foo, and an import for a class, along with a require of the
namespace defining a deftype or defrecord.

An already required namespace now gets the alias or refer added to its
libspec, which cider-ns-add-require benefits from as well: requiring a
namespace that's there without an alias adds the alias instead of
reporting it as required. One with only :as-alias doesn't load the
namespace, so a new libspec goes next to it. What can't work is an
error rather than a silent no-op: a second alias for a namespace, or a
refer of a name another libspec already refers.

The request checks for cider/resolve-missing itself rather than going
through the usual fallback to unprefixed op names, as refactor-nrepl
answers resolve-missing in a different format. When the op fails, that's
an error rather than finding nothing.
cider-ns-add-missing needs its cider/resolve-missing op.
@bbatsov
bbatsov merged commit 3dd6fc8 into master Oct 24, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant