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

Function declaredValueParameters

src/resolution/type-parameters.ts:223–260  ·  view source on GitHub ↗

* A Scala def's value parameters, every curried list: `def f[A](fa: F[A])(f: * A => B)(implicit G: Applicative[G])` → fa, f, G.

(node: Node, context: ResolutionContext)

Source from the content-addressed store, hash-verified

221 * A => B)(implicit G: Applicative[G])` → fa, f, G.
222 */
223function declaredValueParameters(node: Node, context: ResolutionContext): ReadonlySet<string> {
224 let memo = valueMemos.get(context);
225 if (!memo) {
226 memo = new Map();
227 valueMemos.set(context, memo);
228 }
229 const hit = memo.get(node.id);
230 if (hit) return hit;
231 const names = new Set<string>();
232 const lines = context.getFileLines?.(node.filePath) ?? context.readFile(node.filePath)?.split(/\r?\n/) ?? null;
233 if (lines) {
234 const head = lines.slice(node.startLine - 1, Math.min(node.endLine, node.startLine - 1 + HEAD_LINES)).join('\n');
235 const at = nameIndex(head, node.name);
236 if (at >= 0) {
237 let i = at + node.name.length;
238 const skipSpace = (): void => {
239 while (i < head.length && /\s/.test(head[i]!)) i++;
240 };
241 skipSpace();
242 if (head[i] === '[') {
243 const close = matchingBracket(head, i);
244 i = close < 0 ? head.length : close + 1;
245 }
246 for (skipSpace(); head[i] === '('; skipSpace()) {
247 const close = matchingBracket(head, i);
248 if (close < 0) break;
249 for (const item of splitTopLevel(head.slice(i + 1, close), false)) {
250 const bare = item.replace(/^\s*(?:@[\w.]+(?:\([^()]*\))?\s*)+/, '');
251 const param = /^\s*(?:(?:implicit|using|val|var|override|private|protected|final|inline|erased)\s+)*([A-Za-z_]\w*)\s*:/.exec(bare)?.[1];
252 if (param) names.add(param);
253 }
254 i = close + 1;
255 }
256 }
257 }
258 memo.set(node.id, names);
259 return names;
260}
261
262/**
263 * The declared name's position in its head: the whole word, past attributes

Callers 1

gateTypeParameterFunction · 0.85

Calls 11

nameIndexFunction · 0.85
getFileLinesMethod · 0.80
skipSpaceFunction · 0.70
matchingBracketFunction · 0.70
splitTopLevelFunction · 0.70
getMethod · 0.65
readFileMethod · 0.65
execMethod · 0.65
setMethod · 0.45
joinMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected