Last active
January 13, 2022 15:26
-
-
Save borkdude/e3059d88c907e1523fd11009cc09679c to your computer and use it in GitHub Desktop.
clj-kondo + asami
This file contains 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
;; 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}}}) | |
:analysis)) | |
(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}) | |
var-usages)) | |
@(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 ...] | |
:where | |
[?x :call/arity 3] | |
[?x :var/name assoc]] | |
conn)] | |
(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