This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-07
Channels
- # announcements (2)
- # babashka (18)
- # beginners (45)
- # bristol-clojurians (1)
- # calva (2)
- # cider (8)
- # clara (8)
- # clj-kondo (4)
- # cljdoc (6)
- # clojure (69)
- # clojure-chennai (1)
- # clojure-dev (21)
- # clojure-europe (3)
- # clojure-gamedev (3)
- # clojure-india (1)
- # clojure-italy (4)
- # clojure-nl (5)
- # clojure-norway (1)
- # clojure-spec (7)
- # clojure-uk (70)
- # clojurescript (122)
- # cloverage (5)
- # cursive (2)
- # data-science (3)
- # fulcro (21)
- # graalvm (3)
- # graphql (14)
- # jackdaw (2)
- # jobs (2)
- # lumo (2)
- # malli (1)
- # mount (1)
- # off-topic (22)
- # re-frame (2)
- # reitit (5)
- # ring (7)
- # shadow-cljs (47)
- # spacemacs (11)
- # tools-deps (127)
- # vim (16)
- # xtdb (9)
Is there a clojurescript library that converts the ast returned from the analyzer back to a string?
Yes. Thanks, I think the video goes beyond my needs. Some of the clojure refactoring tools contain ast->string
fns. however, they're quite involved and usually not clojurescript compatible. I was surprised that there weren't a few projects converting an AST to a string. after all that should be easier than going from string to AST.
https://www.youtube.com/watch?v=2SGFeegEt9E might be a starting point.
Yes. Thanks, I think the video goes beyond my needs. Some of the clojure refactoring tools contain ast->string
fns. however, they're quite involved and usually not clojurescript compatible. I was surprised that there weren't a few projects converting an AST to a string. after all that should be easier than going from string to AST.
tools analyzer has a pass to do that (goes from AST to code, then you can jus pr-str to go to string)
thanks @bronsa this would return the entire string for the top level form as well as all children if the AST was to be recursed into, right? For my usecase that's problematic, since I'm looking to update the AST (sometimes deeply) and turn it into a string after.
Hmm, I think the problem is that form
of the parent contains the form
s of all children below
you can update the AST and the emitted code will reflect the current AST, not the original form
Ah perfect! Was mistaken by only looking at https://github.com/clojure/tools.analyzer.jvm/blob/master/src/main/clojure/clojure/tools/analyzer/passes/jvm/emit_form.clj#L17
@bronsa do you foresee issues in CLJS around the quoting https://github.com/clojure/tools.analyzer.jvm/blob/master/src/main/clojure/clojure/tools/analyzer/passes/jvm/emit_form.clj#L71-L77 and splicing https://github.com/clojure/tools.analyzer.jvm/blob/master/src/main/clojure/clojure/tools/analyzer/passes/jvm/emit_form.clj#L120-L123
(for context, this is the pass you should be using https://github.com/clojure/tools.analyzer/blob/master/src/main/clojure/clojure/tools/analyzer/passes/emit_form.clj)