This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-27
Channels
- # announcements (10)
- # beginners (95)
- # biff (2)
- # calva (33)
- # cherry (1)
- # clj-kondo (16)
- # clojure (96)
- # clojure-australia (1)
- # clojure-china (1)
- # clojure-europe (42)
- # clojure-filipino (1)
- # clojure-france (2)
- # clojure-hk (1)
- # clojure-indonesia (1)
- # clojure-japan (1)
- # clojure-korea (1)
- # clojure-my (1)
- # clojure-nl (1)
- # clojure-norway (24)
- # clojure-sg (11)
- # clojure-taiwan (1)
- # clojure-uk (1)
- # clojurescript (21)
- # cursive (22)
- # data-science (3)
- # events (7)
- # fulcro (3)
- # graalvm (4)
- # gratitude (6)
- # helix (11)
- # honeysql (7)
- # hoplon (1)
- # introduce-yourself (1)
- # jobs (2)
- # jobs-discuss (16)
- # lsp (15)
- # malli (14)
- # nbb (73)
- # practicalli (3)
- # reagent (8)
- # reitit (5)
- # releases (1)
- # ring (5)
- # rum (3)
- # sci (17)
- # scittle (7)
- # shadow-cljs (22)
- # tools-deps (26)
- # xtdb (9)
@borkdude Hey, thanks for the heads up on analysis stuff! How can I tell clj-kondo to produce full analysis AST? What I'm seeing right now is only var definitions w/o body AST
Hey! Yes, re-iterating my comment on Reddit: What you get from the analysis data is just data, no AST. But you can match this data on location on whatever AST structure you produce using rewrite-clj.
E.g. getting the fully qualified var name or whether something is a local, etc, you should be able to look up in the analysis data
Oh, I see, I thought there's something new I've missed from clj-kondo. This approach doesn't seem suitable for me. I find it more straightforward to have a full AST map at hand right away, as someone who's not familiar with clj-kondo internals.
Yes, I get that. But to produce such a structure, you can use the clj-kondo analysis. Else you would have to write your static analysis yourself
So while walking the raw rewrite-clj structure, you can look into the clj-kondo analysis if some symbol is a local or var, then add that data and produce your AST.
Hmmm, that makes sense. I can see var defs in analysis output, but not local vars. Is there a config switch for that or something?
yes: https://github.com/clj-kondo/clj-kondo/blob/master/analysis/README.md#extra-analysis
nice! I thought :analysis true
would include everything
ok, I'm seeing the data now. Still it means depending on clj-kondo would mean splitting the analyzer in two pieces and parsing inputs twice: to get vars data from clj-kondo and produce AST for everything else myself, which doesn't feel solid to me.
This approach is what several tools are doing, clojure-lsp being one of them. Works quite well. Yes, if you use a tool do to analysis, it becomes a dependency. Parsing the code twice isn't really a problem, it's only a small fraction of the total time taken.
When clojure-lsp adopted clj-kondo we considering sharing the AST but it wasn't worth the trouble
Good point about macros!
Is it feasible for clj-kondo to detect namespaces with mount/defstate that are not required before mount/start is called (I mean does it has enough context to do such checks)? that leads to some nasty NPEs in packaged jars