def has_call

bend-lint-rules@0.2.0.0 · performance/loop_invariant_call.bend:164

import bend-lint-rules@0.2.0.0/performance/loop_invariant_call.bend as LoopInvariantCall
import Base
import bend-lint-api@0.2.0.0/linter/lint.bend as Lint

164# Whether a call of `target` is among `nodes` or under them, or `found`.
165def has_call(nodes: List<&2, Lint.Node>, +target: String, found: Bool) -> Bool:
166  match nodes found:
167    case _ True{}:
168      True{}
169    case Nil{} False{}:
170      False{}
171    case Con{
172      Lint.Node{
173        Lint.Application{},
174        n,
175        s,
176        Con{Lint.Node{Lint.Reference{t}, rn, rs, rk, rf}, args},
177        f
178      },
179      rest
180    } False{}:
181      has_call(rest, target, has_call(args, target, String.eq(t, target)))
182    case Con{Lint.Node{syntax, n, s, kids, f}, rest} False{}:
183      has_call(rest, target, has_call(kids, target, False{}))

Uses (6)

Used by (1)