Fork me on GitHub
#announcements
<
2020-01-21
>
carocad12:01:25

parcera v0.11.0 is now available with Clojurescript support 🚀 https://github.com/carocad/parcera

parrot 16
❤️ 12
niwinz12:01:22

nice, i just looking for something like this

4
hindol17:01:56

What are some use cases for this library?

carocad18:01:41

@UJRDALZA5 whenever you want to analyze clojure code without worrying about it being executed on your system (see security risks of read-string)

niwinz18:01:54

my use case is a script that collects translation messages on clojurescript code. i have previously used the reader but it need too many hacks because it evaluates some code... with that library i can just parse the files without evaluating it

niwinz18:01:33

@U0LJU20SJ i found that only top level forms have metadata, it is posible to have metadata on "all" expressions? I need line number of expersions...

carocad18:01:48

@U06B73YQJ not sure what you mean. Can you give me an example ?

niwinz19:01:45

right now, if i execute (meta (second (parcera.core/ast somedata))) , it will return something like {:start {:row 272, :column 0}...} but if i do the same over an expression a little deeper, it always returns nil so I deduce that only top level forms has metadata...

niwinz19:01:40

for my use case i need that metadata on all possible forms, because im parsing cljs files and looking for (tr "some.translation.string") ... and it would be awesome have a line number of that form

niwinz19:01:24

Example:

"(form)=>" (:list (:symbol "tr") (:whitespace " ") (:string "\"ds.color-lightbox.title\"") (:whitespace " "))
"(meta)=>" nil
"(form)=>" (:list (:symbol "tr") (:whitespace " ") (:string "\"ds.color-lightbox.add\""))
"(meta)=>" nil

carocad19:01:01

mmmm that is weird …. if I execute the code below on parcera itself all forms have metadata:

(for [node (tree-seq seq? seq (parcera/ast (slurp "./src/clojure/parcera/core.cljc")))
      :when (seq? node)
      :when (not (contains? #{:whitespace :comment} (first node)))]
  (let [code (parcera/code node)]
    [(meta node) (str (subs code 0 (min (count code) 10))
                      " ... ")]))
could you give that a try and let me know ?

niwinz19:01:34

strange, this code works as expected yes...

niwinz19:01:58

i need to investigate more...

carocad19:01:53

parcera should give you metadata on all forms. However, the metadata is only attached to the parser rules, for example [:symbol "hello"] has metadata but "hello" does not. Maybe you are trying to extract it on the wrong place ?

niwinz19:01:35

yeah, im aware of that, I'm trying extract metadata from (:list (:symbol "tr") ...)

carocad19:01:48

let me know if this turns out into a bug 😉

niwinz19:01:26

ok, thanks!!

niwinz19:01:30

im using walk/postwalk, is the unique difference to your code, maybe postwalk is doing something that i don't expect... I go to try with tree-seq...

niwinz19:01:16

Yep, i confirm, postwalk is stripping metadata, sorry for bothering!

carocad19:01:28

oh yeah I think I heard sometime ago about that bug in postwalk. afaik there is a jira ticket for in on clojure core

Alex Miller (Clojure team)15:01:33

Take the 2020 Clojure Community Survey now! https://surveymonkey.com/r/clojure2020 We greatly appreciate your feedback and all results will be released. Survey ends this Thu Jan 23....

👍 16
miro19:01:43

Hello Everyone! Just finished a new blog post (aka tutorial): https://www.titanoboa.io/java-repl.html As you may (or may not) know, my workflow platform tianoboa is also trying to be friendly to java programmers with limited (or no) clojure experience. So to try to bring the clojure experience to the java masses, I created also a REPL for java lambdas (yay!) in titanoboa's GUI. This post explains how it works and how you can use it.

👀 8
practicalli-johnny02:01:33

This channel is for announcing releases of new libraries and their majore updates. Please post articles, tutorials in the #news-and-articles channel. Thank you.