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

Function bindPattern

src/resolution/rust-scopes.ts:622–640  ·  view source on GitHub ↗
(from: number, to: number, kind: RustBinding['kind'], scopeFrom: number, scopeTo: number, scrutinee?: string, callee?: RustClosureCallee)

Source from the content-addressed store, hash-verified

620 else bindings.set(name, [binding]);
621 };
622 const bindPattern = (from: number, to: number, kind: RustBinding['kind'], scopeFrom: number, scopeTo: number, scrutinee?: string, callee?: RustClosureCallee): void => {
623 const emit: Emit = (name, at, site) => add(name, { at, kind, from: scopeFrom, to: scopeTo, site, scrutinee, callee });
624 // A tuple pattern, `(k, v)` or `(i, mut x)`: a name alone at its top is
625 // the tuple's field at its place (a site with no path).
626 const open = skipSpace(code, from);
627 const end = code[open] === '(' ? close.get(open) : undefined;
628 if (end !== undefined && end < to && skipSpace(code, end + 1) >= to) {
629 let index = 0;
630 for (const [a, b] of splitTop(code, open + 1, end, close, false)) {
631 const text = code.slice(a, b);
632 const simple = /^\s*(?:ref\s+)?(?:mut\s+)?([A-Za-z_]\w*)\s*$/.exec(text);
633 if (simple && isBindingName(simple[1]!)) emit(simple[1]!, a + text.lastIndexOf(simple[1]!), { path: '', index });
634 else walkPattern(code, a, b, close, undefined, emit);
635 index++;
636 }
637 return;
638 }
639 walkPattern(code, from, to, close, undefined, emit);
640 };
641 // A parameter `pattern: Type`, or a closure's `pattern`.
642 const param = (from: number, to: number, kind: 'param' | 'closure', scopeFrom: number, scopeTo: number, callee?: RustClosureCallee): void => {
643 const colon = topColon(code, from, to, close);

Callers 2

paramFunction · 0.70
readRustBindingsFunction · 0.70

Calls 7

isBindingNameFunction · 0.85
walkPatternFunction · 0.85
skipSpaceFunction · 0.70
splitTopFunction · 0.70
emitFunction · 0.70
getMethod · 0.65
execMethod · 0.65

Tested by

no test coverage detected