rewrite-clj

https://github.com/clj-commons/rewrite-clj
2019-12-03T01:36:39.331400Z

@lee i just looked at: https://github.com/lread/rewrite-cljc-playground/issues/4 -- on a related note, i have things like:

(defn string-value
  "Return the string value for a node."
  [node]
  (when-let [lines (:lines node)]
    (cs/join "\n" lines)))

(defn string-node?
  "Returns true if node represents a string, else false."
  [node]
  (string-value node))

(defn string?
  "Returns true if zipper represents a string, else false."
  [zloc]
  (some-> zloc rz/node string-node?))

(defn symbol-value
  "Return the symbol value for a node."
  [node]
  (:value node))

(defn symbol-node?
  "Returns true if node represents a symbol, else false."
  [node]
  (clojure.core/symbol? (symbol-value node)))

(defn symbol?
  "Returns true if zipper represents a symbol, else false."
  [zloc]
  (some-> zloc rz/node symbol-node?))

2019-12-03T01:37:14.332200Z

i don't know how well they are implemented, but i'm guessing other users of rewrite-clj* have written similar things.

2019-12-03T01:42:56.332600Z

(fwiw, i did look at: https://github.com/lread/rewrite-cljc-playground/blob/master/todos.org -- but didn't go through the code looking for todos 🙂 )

lread 2019-12-03T02:59:55.334400Z

thanks @sogaiu I’ll create a separate issue for these

2019-12-03T03:08:26.335100Z

thanks! iiuc, clj-kondo has some things that are along these lines in: https://github.com/borkdude/clj-kondo/blob/master/src/clj_kondo/impl/utils.clj -- iiuc, borkdude doesn't currently use the zipper-related functionality so the relevant parts of that file are node-related.