MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / readTypeParameters

Function readTypeParameters

src/resolution/vbnet-receivers.ts:1084–1097  ·  view source on GitHub ↗
(n: Node, context: ResolutionContext)

Source from the content-addressed store, hash-verified

1082}
1083
1084function 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

Callers 1

typeParametersOfFunction · 0.85

Calls 9

codeLinesFunction · 0.85
sitedFunction · 0.85
readTypeFunction · 0.85
mapMethod · 0.80
escapeRegexFunction · 0.70
splitArgsFunction · 0.70
execMethod · 0.65
joinMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected