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

Function param

src/resolution/rust-scopes.ts:535–549  ·  view source on GitHub ↗
(from: number, to: number, kind: 'param' | 'closure', scopeFrom: number, scopeTo: number)

Source from the content-addressed store, hash-verified

533 };
534 // A parameter `pattern: Type`, or a closure's `pattern`.
535 const param = (from: number, to: number, kind: 'param' | 'closure', scopeFrom: number, scopeTo: number): void => {
536 const colon = topColon(code, from, to, close);
537 const pattern = code.slice(from, colon < 0 ? to : colon);
538 const simple = /^\s*(?:mut\s+)?([A-Za-z_]\w*)\s*$/.exec(pattern);
539 if (simple) {
540 if (isBindingName(simple[1]!)) {
541 add(simple[1]!, {
542 at: from + pattern.lastIndexOf(simple[1]!), kind, from: scopeFrom, to: scopeTo,
543 type: colon < 0 ? undefined : code.slice(colon + 1, to).trim(),
544 });
545 }
546 return;
547 }
548 bindPattern(from, colon < 0 ? to : colon, kind, scopeFrom, scopeTo);
549 };
550
551 for (const f of scopes.fns) {
552 for (const [a, b] of splitTop(code, f.from + 1, f.paramsEnd, close, true)) param(a, b, 'param', f.body, f.to);

Callers 1

readRustBindingsFunction · 0.85

Calls 5

topColonFunction · 0.85
isBindingNameFunction · 0.85
addFunction · 0.70
bindPatternFunction · 0.70
execMethod · 0.65

Tested by

no test coverage detected