def calls

bend-lint-rules@0.2.0.0 · performance/missed_fork.bend:123

import bend-lint-rules@0.2.0.0/performance/missed_fork.bend as MissedFork
import Base
import bend-lint-api@0.2.0.0/linter/lint.bend as Lint

123# Where the calls of `target` among `nodes` and under them are (onto `out`, last first), in the expression they start:
124# a node that ends it starts another, and so does each argument of a choice (Bool.pick, Bool.and, Bool.or); a call
125# inside another call of `target` does not count: none does if `nodes` are the parts of one, or of a choice (`inside`).
126def calls(
127  nodes: List<&2, Lint.Node>,
128  +target: String,
129  out: List<&2, Lint.Span>,
130  inside: Bool
131) -> List<&2, Lint.Span>:
132  match nodes inside:
133    case _ True{}:
134      out
135    case Nil{} False{}:
136      out
137    case Con{Lint.Node{Lint.Application{}, n, span, +kids, f}, rest} False{}:
138      +call = calls.to(kids, target)
139      calls(
140        rest,
141        target,
142        calls(kids, target, called.at(call, span, out), call || is_choice(kids)),
143        False{}
144      )
145    case Con{Lint.Node{Lint.Construction{t}, n, s, kids, f}, rest} False{}:
146      calls(rest, target, calls(kids, target, out, False{}), False{})
147    case Con{Lint.Node{Lint.Annotation{}, n, s, kids, f}, rest} False{}:
148      calls(rest, target, calls(kids, target, out, False{}), False{})
149    case Con{node, rest} False{}:
150      calls(rest, target, out, False{})

Uses (10)

Used by (1)