Skip to content

feat(extraction): add Clojure language support - #1460

Open
pkoz wants to merge 1 commit into
colbymchenry:mainfrom
get-miracai:feat/clojure-support
Open

feat(extraction): add Clojure language support#1460
pkoz wants to merge 1 commit into
colbymchenry:mainfrom
get-miracai:feat/clojure-support

Conversation

@pkoz

@pkoz pkoz commented Jul 27, 2026

Copy link
Copy Markdown

Disclaimer: this PR was created with the help of Anthropic's Opus 5

Clojure is homoiconic — there are no definition node types. (defn f [x]), (if a b) and (foo 1) are all the same list_lit node, and meaning comes from the head symbol. Mapping functionTypes: ['list_lit'] would classify every form in the language as a function, so every declarative node-type list is empty and extraction runs entirely through the visitNode hook — the one the core documents for languages with fundamentally different AST structures.

Grammar vendored from sogaiu/tree-sitter-clojure @ e43eff8 (CC0-1.0), built with tree-sitter-cli 0.26.11 (build --wasm, ABI 14). Passes the project's grammar health check; the module statically links no libc.

Maps defn/defn-/defmacro/definline/defmulti/deftest to functions, defmethod to methods, defprotocol/definterface to interfaces, defrecord/deftype to classes, def/defonce/defstate to constants, and ns to a module with :require/:import edges. Captures alias-qualified and bare calls, and #'var quoted references so private vars reached from test suites still resolve to callers.

DEF_KINDS is a Map, not an object literal: (Long/valueOf x) reduces to the bare name valueOf, which on an object literal resolves to Object.prototype.valueOf — a function — which then became a node kind and killed the parse worker with a non-cloneable node. Capitalised symbol namespaces are treated as host interop and excluded from call edges.

Verified on a 1,094-file Clojure repo: 1.2s, zero parse errors, namespace / multimethod / record counts exact against ground truth.

Clojure is homoiconic — there are no definition node types. `(defn f [x])`,
`(if a b)` and `(foo 1)` are all the same `list_lit` node, and meaning comes
from the head symbol. Mapping `functionTypes: ['list_lit']` would classify
every form in the language as a function, so every declarative node-type list
is empty and extraction runs entirely through the `visitNode` hook — the one
the core documents for languages with fundamentally different AST structures.

Grammar vendored from sogaiu/tree-sitter-clojure @ e43eff8 (CC0-1.0), built
with tree-sitter-cli 0.26.11 (`build --wasm`, ABI 14). Passes the project's
grammar health check; the module statically links no libc.

Maps defn/defn-/defmacro/definline/defmulti/deftest to functions, defmethod to
methods, defprotocol/definterface to interfaces, defrecord/deftype to classes,
def/defonce/defstate to constants, and ns to a module with :require/:import
edges. Captures alias-qualified and bare calls, and `#'var` quoted references
so private vars reached from test suites still resolve to callers.

DEF_KINDS is a Map, not an object literal: `(Long/valueOf x)` reduces to the
bare name `valueOf`, which on an object literal resolves to
Object.prototype.valueOf — a function — which then became a node kind and
killed the parse worker with a non-cloneable node. Capitalised symbol
namespaces are treated as host interop and excluded from call edges.

Verified on a 1,094-file Clojure repo: 1.2s, zero parse errors, namespace /
multimethod / record counts exact against ground truth.
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