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

Function opensClosure

src/resolution/rust-scopes.ts:379–389  ·  view source on GitHub ↗

* Whether a `|` at `i` opens a closure's parameter list: it stands where an * expression starts — after `(`, `[`, `{`, `,`, `=`, `;`, `:`, `=>`, or * `move` / `return` / `async` — never after an operand, where it is an `|` * of bits or a pattern's alternative.

(code: string, i: number)

Source from the content-addressed store, hash-verified

377 * of bits or a pattern's alternative.
378 */
379function opensClosure(code: string, i: number): boolean {
380 let k = i - 1;
381 while (k >= 0 && /\s/.test(code[k]!)) k--;
382 if (k < 0) return true;
383 const c = code[k]!;
384 if (c === ':') return code[k - 1] !== ':';
385 if ('([{,=;'.includes(c)) return true;
386 if (c === '>') return code[k - 1] === '=';
387 const word = /([A-Za-z_]\w*)$/.exec(code.slice(Math.max(0, k - 8), k + 1))?.[1];
388 return word === 'move' || word === 'return' || word === 'async' || word === 'static';
389}
390
391/** Where an expression starting at `from` ends: its first top-level `,` or `;`, or the bracket closing around it. */
392function expressionEnd(code: string, from: number, close: Map<number, number>): number {

Callers 1

readRustBindingsFunction · 0.85

Calls 1

execMethod · 0.65

Tested by

no test coverage detected