def templates
bend-lint-rules@0.2.0.0 · performance/template_value_field.bend:84
import bend-lint-rules@0.2.0.0/performance/template_value_field.bend as TemplateValueField
import Base
import bend-lint-api@0.2.0.0/linter/lint.bend as Lint
import bend-lint-api@0.2.0.0/shared/lists.bend as Lists
84
85def templates(
86 nodes: List<&2, Lint.Node>,
87 +records: List<&2, String>,
88 out: List<&2, U32>
89) -> List<&2, U32>:
90 match nodes:
91 case Nil{}:
92 out
93 case Con{Lint.Node{Lint.Parameter{b, Lint.Template{}}, n, s, kids, f}, rest}:
94 templates(
95 rest,
96 records,
97 Lists.push(
98 U32,
99 Lists.when(U32, List.contains(~String, ~String.eq, records, written(kids)), b),
100 out
101 )
102 )
103 case Con{node, rest}:
104 templates(rest, records, out)