(n: Node, context: ResolutionContext)
| 1082 | } |
| 1083 | |
| 1084 | function readTypeParameters(n: Node, context: ResolutionContext): Map<string, VbType | null> { |
| 1085 | const params = new Map<string, VbType | null>(); |
| 1086 | const code = codeLines(n.filePath, context).slice(n.startLine - 1, n.startLine + 2).join(' '); |
| 1087 | const head = new RegExp(`\\b(?:Class|Structure|Interface|Module|Function|Sub)\\s+${escapeRegex(n.name)}\\s*(?=\\(\\s*Of\\b)`, 'i').exec(code); |
| 1088 | if (!head) return params; |
| 1089 | for (const p of splitArgs(code, head.index + head[0].length) ?? []) { |
| 1090 | const m = /^(?:Of\s+)?(?:In\s+|Out\s+)?([A-Za-z_]\w*)(?:\s+As\s+(.+))?$/i.exec(p); |
| 1091 | if (!m) continue; |
| 1092 | const constraints = (m[2] ?? '').replace(/^\{|\}$/g, '').split(',').map((c) => c.trim()) |
| 1093 | .filter((c) => c !== '' && !/^(?:New|Class|Structure)$/i.test(c)); |
| 1094 | params.set(m[1]!.toLowerCase(), constraints.length > 0 ? sited(readType(constraints[0]!, 0), n.filePath, n.startLine) : null); |
| 1095 | } |
| 1096 | return params; |
| 1097 | } |
| 1098 | |
| 1099 | /** |
| 1100 | * What a type means where it is written: a type parameter of the method |
no test coverage detected