/
seq.clj
36 lines (32 loc) · 973 Bytes
/
seq.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
(ns clj-kondo.impl.node.seq
(:require [rewrite-clj.node.protocols :as node]))
(defrecord NamespacedMapNode [children aliased?]
node/Node
(tag [this]
:namespaced-map)
(printable-only? [_] false)
(sexpr [this]
(let [[nspace-k m] (node/sexprs children)
nspace (name nspace-k)]
(->> (for [[k v] m
:let [k' (cond (not (keyword? k)) k
(namespace k) k
:else (keyword nspace (name k)))]]
[k' v])
(into {}))))
(length [_]
(+ 1 (node/sum-lengths children)))
(string [this]
(str "#" (node/concat-strings children)))
node/InnerNode
(inner? [_] true)
(children [_] children)
(replace-children [this children']
(assoc this :children children'))
(leader-length [_]
1)
Object
(toString [this]
(node/string this)))
(defn namespaced-map-node [children aliased?]
(->NamespacedMapNode children aliased?))