This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-26
Channels
- # announcements (17)
- # babashka (68)
- # beginners (8)
- # biff (14)
- # calva (25)
- # cherry (10)
- # clj-kondo (1)
- # clj-on-windows (12)
- # cljsrn (6)
- # clojure (134)
- # clojure-berlin (1)
- # clojure-europe (33)
- # clojure-nl (4)
- # clojure-norway (6)
- # clojure-uk (10)
- # clojurescript (9)
- # datalevin (8)
- # datomic (34)
- # docker (1)
- # emacs (31)
- # fulcro (6)
- # honeysql (8)
- # java (7)
- # joyride (14)
- # kaocha (7)
- # malli (11)
- # nbb (4)
- # off-topic (11)
- # pedestal (14)
- # rdf (53)
- # re-frame (6)
- # reagent (39)
- # reitit (2)
- # releases (9)
- # rewrite-clj (14)
- # shadow-cljs (97)
- # specter (1)
- # testing (5)
- # tools-deps (12)
- # vim (4)
- # xtdb (9)
Please, can someone point me out the example of code that statically analyses symbol resolution?
(ns user
(:require [foo.bar :refer [baz] :as foobar]))
(println foobar/baz)
(println baz)
I would like to study from someone's code that can resolve baz
and foobar/baz
to foo.bar/baz
, and also can handle things like let
-bindings, etcThatโs #CHY97NXE2
statically analyzing ns
is actually quite difficult because it is so so flexible. Highly recommend using kondo as a library for static analysis to leverage the community effort. Though you can look at early clojure-lsp (parser.clj)
commits before we switched to kondo.
So, you folks confirmed I have to dive in the clj-kondo
source, which seems a bit scary to me for now ๐
Yeah, I want to adapt some code for the CLJS, not necessary the most elaborate implementation
here's the pr, so just before this. https://github.com/clojure-lsp/clojure-lsp/pull/261/commits/a1ee3756c88b70609befc5bce5ca0b11a92770f1
I know clj-kondo seems scary, but it's honestly quite readable. If you start from https://github.com/clj-kondo/clj-kondo/blob/707454f78069c59811405c010c2349c0b33fda47/src/clj_kondo/main.clj#L184, trace the calls: > clj-kondo.main/-main -> clj-kondo.main/main -> clj-kondo.core/run! -> clj-kondo.core.impl/process-files -> clj-kondo.core.impl/process-file -> clj-kondo.core.impl/schedule (assuming not parallel for simplicity) -> clj-kondo.impl.analyzer/analyze-input -> clj-kondo.impl.analyzer/analyze-expressions and then at that point, clj-kondo loops over every top-level expression in the parsed input (from the file or string) and uses recursion to handle all sub-expressions (with clj-kondo.impl.analyzer/analyze-expression**). @U04V15CAJ is also very helpful if you have questions about how it all works
@U0BUV7XSA that's a cool PR! I didn't know that clojure-lsp did its own analysis before using clj-kondo.
@U0GA10KA8 You don't have to read the source code of clj-kondo to be able to use its analysis: https://github.com/clj-kondo/clj-kondo/blob/master/analysis/README.md
Just found it, looks like it provides everything I need (and even much more). Ideally, I'm aiming to have self-contained node.js
library in the project I'm playing with.