Skip to content

Fix lookups in ClojureScript, bare namespaces and Java - #28

Merged
bbatsov merged 5 commits into
mainfrom
lookups-polish
Oct 20, 2026
Merged

bbatsov merged 5 commits into
mainfrom
lookups-polish

Conversation

@bbatsov

@bbatsov bbatsov commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

source now reads definitions from the file and line info gives, the way CIDER does, which is what makes it work after neorepl load and in ClojureScript. The other commits fix lookups that failed in namespaces made by in-ns, Java members and classes that came back as nothing or as raw Javadoc, and ,macroexpand replacing *1.

--session for the lookups is the one new feature. In a ClojureScript session it only knows the Clojure namespace underneath, because that's all describe reports, so --ns names the ClojureScript one until piggieback reports it.

The fallbacks that evaluate code, for servers without cider-nrepl or
nREPL's lookup, and source always, ran in the namespace looked in, using
require and symbol unqualified, so they failed in a namespace that doesn't
refer clojure.core, like one in-ns made. They now compile in user, after
requiring what they need in a top-level form of its own, with *ns* bound
to the namespace looked in.
cider-nrepl's info for a Java member has no name, but a class and a
member, so doc said there was nothing called Thread/sleep, and the REPL
showed no arglists for (.toUpperCase, while a class's doc was raw Javadoc.
The member's class now stands for its namespace and the class for a class's
name, and the doc comes from cider-nrepl's Javadoc fragments, as text. A
field's arglists, which come as nil, are left out, and a namespace's info,
which names it twice, loses its :ns, so it's named once.
clojure.repl/source-fn only reads files on the classpath, so source found
nothing after neorepl load of a file from anywhere else, which breaks the
skill's load then look up, nor anything in ClojureScript. source now reads
the definition from the file and line info gives, as CIDER does, as far as
the form goes, and falls back to source-fn for a file this machine can't
read. It takes the form only if it's a definition, since cider-nrepl gives
the macros ClojureScript takes from Clojure lines from somewhere else.
cider-nrepl's macroexpand evaluates in the session it's given, so
,macroexpand left its expansion as the REPL's *1. It now goes to a copy of
the session, which keeps its language.
The CLI's lookups looked in user, or --ns, and outside any session, so
they couldn't reach a session's ClojureScript, nor the namespace it's in,
and neither could the MCP tools. --session NAME, and the tools' session,
which is agent by default there, now send the lookups to that session, in
its namespace unless --ns says otherwise. In ClojureScript that's the
Clojure namespace under it, which is all describe has.
@bbatsov
bbatsov merged commit c2a1f52 into main Oct 20, 2026
18 checks passed
@bbatsov
bbatsov deleted the lookups-polish branch October 20, 2026 04:48
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