File tree Expand file tree Collapse file tree 2 files changed +73
-1
lines changed Expand file tree Collapse file tree 2 files changed +73
-1
lines changed Original file line number Diff line number Diff line change 9
9
:hooks {:analyze-call
10
10
{manifold.stream.core/def-source manifold.hooks/def-sink-or-source
11
11
manifold.stream.core/def-sink manifold.hooks/def-sink-or-source
12
- manifold.stream.core/def-sink+source manifold.hooks/def-sink-or-source}}
12
+ manifold.stream.core/def-sink+source manifold.hooks/def-sink-or-source
13
+ manifold.deferred/both manifold.hooks/both
14
+ manifold.deferred/success-error-unrealized manifold.hooks/success-error-unrealized}}
13
15
14
16
15
17
:config-in-call {manifold.stream.core/def-sink+source
Original file line number Diff line number Diff line change 28
28
(api/token-node (symbol (str " ->" (:string-value name))))
29
29
bindings
30
30
))))}))
31
+
32
+ (defn- seq-node? [node]
33
+ (or (api/vector-node? node)
34
+ (api/list-node? node)))
35
+
36
+ (defn- nth-child [node n] (nth (:children node) n))
37
+
38
+ (defn both [call]
39
+ (let [body (-> call :node :children second :children )]
40
+
41
+ {:node
42
+ (api/list-node
43
+ (list
44
+ (api/token-node 'do)
45
+
46
+ (api/list-node
47
+ (->> body
48
+ (mapcat
49
+ #(if (and (seq-node? %) (= 'either (:value (nth-child % 0 ))))
50
+ (:children (nth-child % 1 ))
51
+ [%]))))
52
+
53
+ (api/list-node
54
+ (->> body
55
+ (mapcat
56
+ #(if (and (seq-node? %) (= 'either (:value (nth-child % 0 ))))
57
+ (:children (nth-child % 2 ))
58
+ [%]))))))}))
59
+
60
+
61
+ (def fallback-value
62
+ " The fallback value used for declaration of local variables whose
63
+ values are unknown at lint time."
64
+ (api/list-node
65
+ (list
66
+ (api/token-node 'new)
67
+ (api/token-node 'java.lang.Object))))
68
+
69
+ (defn success-error-unrealized [call]
70
+
71
+ (let [[deferred
72
+ success-value success-clause
73
+ error-value error-clause
74
+ unrealized-clause] (-> call :node :children rest)]
75
+
76
+ (when-not (and deferred success-value success-clause error-value
77
+ error-clause unrealized-clause)
78
+ (throw (ex-info " Missing success-error-unrealized arguments" {})))
79
+
80
+ {:node
81
+ (api/list-node
82
+ (list
83
+ (api/token-node 'do)
84
+
85
+ (api/list-node
86
+ (list
87
+ (api/token-node 'let)
88
+ (api/vector-node (vector success-value fallback-value))
89
+ success-clause
90
+ ))
91
+
92
+ (api/list-node
93
+ (list
94
+ (api/token-node 'let)
95
+ (api/vector-node (vector error-value fallback-value))
96
+ error-clause
97
+ ))
98
+
99
+ unrealized-clause
100
+ ))}))
You can’t perform that action at this time.
0 commit comments