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

Function pastBracket

src/extraction/razor-script.ts:41–61  ·  view source on GitHub ↗

Index just past the bracket closing the one at `open`, or -1. Strings and comments hold no brackets.

(s: string, open: number)

Source from the content-addressed store, hash-verified

39
40/** Index just past the bracket closing the one at `open`, or -1. Strings and comments hold no brackets. */
41function pastBracket(s: string, open: number): number {
42 const stack = [CLOSER[s[open]!]!];
43 for (let i = open + 1; i < s.length; i++) {
44 const c = s[i]!;
45 if (c === '"' || c === "'") {
46 i = skipString(s, i) - 1;
47 } else if (c === '/' && s[i + 1] === '/') {
48 while (i < s.length && s[i] !== '\n') i++;
49 } else if (c === '/' && s[i + 1] === '*') {
50 const end = s.indexOf('*/', i + 2);
51 if (end < 0) return -1;
52 i = end + 1;
53 } else if (CLOSER[c]) {
54 stack.push(CLOSER[c]!);
55 } else if (c === stack[stack.length - 1]) {
56 stack.pop();
57 if (stack.length === 0) return i + 1;
58 }
59 }
60 return -1;
61}
62
63function blank(out: string[], from: number, to: number): void {
64 for (let i = from; i < to; i++) if (out[i] !== '\n' && out[i] !== '\r') out[i] = ' ';

Callers 3

pastExpressionFunction · 0.85
blankControlFunction · 0.85
blankRazorFunction · 0.85

Calls 2

pushMethod · 0.80
skipStringFunction · 0.70

Tested by

no test coverage detected