def called

bolt@1.27.0.0 · src/rules/suspicious/eager.bend:31

import bolt@1.27.0.0/src/rules/suspicious/eager.bend as Eager
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

31# every name a node calls, `f(..)`, at any depth
32def called(nn: Tree.Node) -> List<&2, String>:
33  match nn:
34    case Tree.NCons{Tree.Leaf{Lex.Tok{k, +t, l, c}}, Tree.NCons{Tree.Group{Lex.Tok{_, +o, _, _}, +kids, _}, rest}}:
35      +more = List.concat(&2, String, [called(kids), called(rest)])
36      Bool.pick(List<&2, String>, String.eq(o, "("), t <> more, more)
37    case Tree.NCons{Tree.Group{open, +kids, close}, rest}:
38      List.concat(&2, String, [called(kids), called(rest)])
39    case Tree.NCons{Tree.Stmt{kind, +kids, body}, rest}:
40      List.concat(&2, String, [called(kids), called(body), called(rest)])
41    case Tree.NCons{h, rest}:
42      called(rest)
43    case other:
44      Nil{}

Uses (7)

Used by (1)