Skip to content

Commit

Permalink
Add linter support for flutter/build (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
valerauko authored Dec 4, 2023
1 parent fca6e1d commit 8da5840
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
Sink StackOverflowError StackTrace StateError Stopwatch String StringBuffer StringSink
Symbol Type TypeError UnimplementedError UnsupportedError Uri WeakReference]}}
:hooks {:analyze-call {cljd.flutter.alpha/widget hooks.flutter/widget
cljd.flutter/build hooks.flutter2/analyze-build
cljd.flutter/run hooks.flutter2/widget
cljd.flutter/widget hooks.flutter2/widget}}}
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,26 @@
(m/ElevatedButton .onPressed #(swap! counters update k inc))
(m/Text +))
")}))))

(defn analyze-build
"Rewrite build into an fn with a f/widget call as the body"
[{:keys [node]}]
(let [[argsvec? & body :as children] (-> node :children rest)
widget-node
(->> (api/list-node
(list*
(api/token-node 'cljd.flutter/widget)
(if (api/vector-node? argsvec?)
body
children)))
(assoc {} :node)
widget :node)
result
(api/list-node
(list
(api/token-node 'fn)
(if (api/vector-node? argsvec?)
argsvec?
(api/vector-node []))
widget-node))]
{:node result}))

0 comments on commit 8da5840

Please sign in to comment.