Rewalk.hits: def of bolt@1.27.0.0 Import: import bolt@1.27.0.0/src/rules/pedantic/rewalk.bend as Rewalk Lines 323-354 of bolt@1.27.0.0/src/rules/pedantic/rewalk.bend: https://jend.leeeet.dev/read.txt?path=bolt@1.27.0.0/src/rules/pedantic/rewalk.bend&start_line=323&end_line=354 import Base import bolt@1.27.0.0/src/syntax/lex.bend as Lex import bolt@1.27.0.0/src/syntax/tree.bend as Tree # reads of the name. hot: this chain is a collection argument. live/left: commas # count toward that argument. skip: ignore names until `=` (the left of a let) def hits(nn: Tree.Node, +name: String, +hot: Bool, +left: Nat, +live: Bool, +skip: Bool) -> Hit: match nn: case Tree.NCons{Tree.Leaf{Lex.Tok{Lex.TEq{}, t, l, c}}, rest}: hits(rest, name, hot, left, live, False{}) case Tree.NCons{Tree.Leaf{Lex.Tok{Lex.TComma{}, t, l, c}}, rest}: hits(rest, name, step_hot(hot, left, live), step_left(left, live), live, skip) case Tree.NCons{Tree.Leaf{Lex.Tok{k, +t, l, c}}, Tree.NCons{Tree.Group{Lex.Tok{_, +o, _, _}, +kids, _}, rest}}: +brack = String.eq(o, "[") +call = String.eq(o, "(") +here = hit_keep(skip, here_hit(brack, call, t, name, hot)) +inn = hits(kids, name, pick_hot(skip, brack, call, hot), pick_left(skip, brack, call, t), pick_live(skip, brack, call, t), skip) +aft = hits(rest, name, hot, left, live, skip) either(here, either(inn, aft)) case Tree.NCons{Tree.Leaf{Lex.Tok{Lex.TName{}, +t, l, c}}, rest}: either(hit_keep(skip, name_hit(String.eq(t, name), hot)), hits(rest, name, hot, left, live, skip)) case Tree.NCons{Tree.Leaf{tok}, rest}: hits(rest, name, hot, left, live, skip) case Tree.NCons{Tree.Group{open, +kids, close}, rest}: either(hits(kids, name, hot, 0n, False{}, skip), hits(rest, name, hot, left, live, skip)) case Tree.NCons{Tree.Stmt{kind, +kids, body}, rest}: +eq = has_eq(kids) +inn = hits(kids, name, False{}, 0n, False{}, eq) +bod = hits(body, name, False{}, 0n, False{}, False{}) +aft = hits(rest, name, hot, left, live, skip) either(inn, either(bod, aft)) case Tree.NCons{h, rest}: hits(rest, name, hot, left, live, skip) case other: none_hit() Uses (19): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String.eq https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/rules/pedantic/rewalk.bend&name=Hit https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/rules/pedantic/rewalk.bend&name=either https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/rules/pedantic/rewalk.bend&name=has_eq https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/rules/pedantic/rewalk.bend&name=here_hit https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/rules/pedantic/rewalk.bend&name=hit_keep https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/rules/pedantic/rewalk.bend&name=name_hit https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/rules/pedantic/rewalk.bend&name=none_hit https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/rules/pedantic/rewalk.bend&name=pick_hot https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/rules/pedantic/rewalk.bend&name=pick_left https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/rules/pedantic/rewalk.bend&name=pick_live https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/rules/pedantic/rewalk.bend&name=step_hot https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/rules/pedantic/rewalk.bend&name=step_left https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/lex.bend&name=Tok https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/lex.bend&name=TokKind https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/tree.bend&name=Node