* The project's Pascal types a name names, generic ones by the name before * their parameters: `TSetParams ` for `TSetParams`.
(lower: string, context: ResolutionContext)
| 1190 | * their parameters: `TSetParams<T: class>` for `TSetParams`. |
| 1191 | */ |
| 1192 | function typesNamed(lower: string, context: ResolutionContext): Node[] { |
| 1193 | const m = memos(context); |
| 1194 | if (!m.genericTypes) { |
| 1195 | const generic = new Map<string, Node[]>(); |
| 1196 | const add = (n: Node): void => { |
| 1197 | const open = n.name.indexOf('<'); |
| 1198 | if (n.language !== 'pascal' || open <= 0 || !(n.kind === 'type_alias' || CLASS_KINDS.has(n.kind))) return; |
| 1199 | const base = n.name.slice(0, open).trim().toLowerCase(); |
| 1200 | const list = generic.get(base); |
| 1201 | if (list) list.push(n); |
| 1202 | else generic.set(base, [n]); |
| 1203 | }; |
| 1204 | const kinds = ['type_alias', 'class', 'struct', 'interface'] as const; |
| 1205 | // The names alone first, where the index can tell them, to fetch only |
| 1206 | // the generic types. |
| 1207 | const names = context.getNodeNamesOfKinds?.('pascal', kinds); |
| 1208 | if (names) { |
| 1209 | for (const name of new Set(names)) if (name.includes('<')) context.getNodesByName(name).forEach(add); |
| 1210 | } else { |
| 1211 | for (const kind of kinds) for (const n of context.iterateNodesByKind?.(kind) ?? context.getNodesByKind(kind)) add(n); |
| 1212 | } |
| 1213 | m.genericTypes = generic; |
| 1214 | } |
| 1215 | return pascalNamed(lower, context).filter((t) => t.kind === 'type_alias' || CLASS_KINDS.has(t.kind)) |
| 1216 | .concat(m.genericTypes.get(lower) ?? []); |
| 1217 | } |
| 1218 | |
| 1219 | /** |
| 1220 | * What a type declaration says after its `=`, which may start on the next |
no test coverage detected