def type_head.go

bolt@1.27.0.0 · src/rules/calls.bend:216

import bolt@1.27.0.0/src/rules/calls.bend as Calls
import Base
import bolt@1.27.0.0/src/syntax/tree.bend as Tree

216# the head of a parameter's type: the first capitalized name after the
217# colon, "" for none; hit: a name before pp was it, so the search stops there
218def type_head.go(pp: Tree.Node, +after: Bool, hit: Maybe<&2, String>) -> String:
219  match pp:
220    case Tree.NCons{+h, rest}:
221      match hit:
222        case Some{s}:
223          s
224        case None{}:
225          type_head.go(rest, Bool.or(after, kind.leaf(~kind.colon, h)),
226            Bool.pick(Maybe<&2, String>, Bool.and(after, kind.leaf(~kind.upper, h)), Some{leaf.text(h)}, None{}))
227    case other:
228      match hit:
229        case Some{s}:
230          s
231        case None{}:
232          ""

Uses (11)

Used by (1)