I contributed Clojure and EDN support to Ataraxy Labs’ sem tool (https://github.com/Ataraxy-Labs/sem) at the weekend.
It’s a diff/blame/impact tool, that outputs in terms of tree-sitter semantic entities. Its impact analysis will show you where an entity (e.g. a function or a macro) sits in the dependency graph.
$ sem impact --entity-id "src/still/snapshot.cljc::function::file-exists?@L84"
⊕ function file-exists? (src/still/snapshot.cljc:84–87)
← depended on by:
← function read-snapshot (src/still/snapshot.cljc)
← function snapshot-exists? (src/still/snapshot.cljc)
← function delete-snapshot! (src/still/snapshot.cljc)
← function snapshot-metadata (src/still/snapshot.cljc)
! 7 entities transitively affected (depth 2):
Direct dependents (4)
→ function read-snapshot (src/still/snapshot.cljc:L168)
→ function snapshot-exists? (src/still/snapshot.cljc:L198)
→ function delete-snapshot! (src/still/snapshot.cljc:L203)
→ function snapshot-metadata (src/still/snapshot.cljc:L251)
Depth 2 (3)
→ function snap (src/still/core.cljc:L138)
→ function cleanup-test-snapshots (test/still/snapshot_test.cljc:L16)
→ function delete-all-snapshots! (src/still/update.cljc:L50)
You’ll have to build from (Rust) source at the moment to get it with Clojure support.Nice! What libraries did you use for parsing the Clojure source and EDN?
sem uses tree-sitter to parse the syntax tree, so I just had to add the tree-sitter-clojure-orchard Rust crate.
that was the easy bit – downstream of parsing there were a lot of algol-ish assumptions in the graph building that broke with Clojure code (e.g. splitting tokens on - and considering anything after a # to be a comment).
all of that stuff is parameterised in the language config now, so it should be much more straightforward to add other lisps.
That's great!
Very nice. I hoped the old codeq project would grow into something like this.