Skip to content

Instantly share code, notes, and snippets.

Last active Jan 13, 2022
What would you like to do?
clj-kondo + asami
;; deps.edn:
;; {
;; :deps {
;; clj-kondo/clj-kondo {:mvn/version "2021.10.19"}
;; org.clojars.quoll/asami {:mvn/version "2.2.3"}
;; }
;; }
(ns kondami.scratch
(:require [asami.core :as d]
[clj-kondo.core :as clj-kondo]))
(def db-uri "asami:mem://dbname")
(d/create-database db-uri)
(def conn (d/connect db-uri))
(def analysis (-> (clj-kondo/run! {:lint ["src"]
:config {:output {:analysis true}}})
(def var-usages (:var-usages analysis))
(def processed (map (fn [{:keys [arity name to row col filename]}]
{:call/arity arity
:call/row row
:call/col col
:call/file filename
:var/name name
:var/ns to})
@(d/transact conn {:tx-data processed})
(def db (d/db conn))
(assoc {} :a 1) ;; try to find this one
(let [entities (d/q '[:find [?x ...]
[?x :call/arity 3]
[?x :var/name assoc]]
(map #(d/entity conn %) entities))
;; result:
;; {:call/arity 3,
;; :call/row 19,
;; :call/col 1,
;; :call/file "src/kondami/scratch.clj",
;; :var/name assoc,
;; :var/ns clojure.core}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment