feat(extraction): add Clojure language support - #1460
Open
pkoz wants to merge 1 commit into
Open
Conversation
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.
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.
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 samelist_litnode, and meaning comes from the head symbol. MappingfunctionTypes: ['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 thevisitNodehook — 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
#'varquoted 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 namevalueOf, 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.