/
uneval.clj
41 lines (34 loc) · 906 Bytes
/
uneval.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
(ns ^:no-doc rewrite-clj.node.uneval
(:require [rewrite-clj.node.protocols :as node]))
;; ## Node
(defrecord UnevalNode [children]
node/Node
(tag [_] :uneval)
(printable-only? [_] true)
(sexpr [_]
(throw (UnsupportedOperationException.)))
(length [_]
(+ 2 (node/sum-lengths children)))
(string [_]
(str "#_" (node/concat-strings children)))
node/InnerNode
(inner? [_] true)
(children [_] children)
(replace-children [this children']
(node/assert-single-sexpr children')
(assoc this :children children'))
(leader-length [_]
2)
Object
(toString [this]
(node/string this)))
(node/make-printable! UnevalNode)
;; ## Constructor
(defn uneval-node
"Create node representing an EDN uneval `#_` form."
[children]
(if (sequential? children)
(do
(node/assert-single-sexpr children)
(->UnevalNode children))
(recur [children])))