def walk
bolt@1.27.0.0 · src/rules/style/transcong.bend:151
import bolt@1.27.0.0/src/rules/style/transcong.bend as Transcong
import Base
import bolt@1.27.0.0/src/finding.bend as F
import bolt@1.27.0.0/src/syntax/tree.bend as Tree
151
152
153def walk(nn: Tree.Node, +top: Bool, +path: String) -> List<&2, F.Finding>:
154 match nn:
155 case Tree.NCons{+h, +rest}:
156 +here = site(h, rest, path)
157 List.concat(&2, F.Finding, [Bool.pick(List<&2, F.Finding>, top, here, []), walk(h, True{}, path),
158 walk(rest, Bool.and(top, Bool.not(binds(h))), path)])
159 case Tree.Group{_o, kids, _cl}:
160 walk(kids, True{}, path)
161 case Tree.Stmt{sk, kids, body}:
162 List.concat(&2, F.Finding, [walk(kids, Bool.not(is_let(sk)), path), walk(body, True{}, path)])
163 case _other:
164 Nil{}