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

Function pastExpression

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

Past an implicit expression starting at `at` (after the `@`): names, members, calls and indexers.

(s: string, at: number)

Source from the content-addressed store, hash-verified

66
67/** Past an implicit expression starting at `at` (after the `@`): names, members, calls and indexers. */
68function pastExpression(s: string, at: number): number {
69 let i = at;
70 const awaited = /^await\s+/.exec(s.slice(i, i + 16));
71 if (awaited) i += awaited[0].length;
72 const name = /^[A-Za-z_]\w*/.exec(s.slice(i, i + 128));
73 if (!name) return at;
74 i += name[0].length;
75 for (;;) {
76 const c = s[i];
77 if (c === '(' || c === '[') {
78 const end = pastBracket(s, i);
79 if (end < 0) return i;
80 i = end;
81 } else if (c === '<' && /^<[A-Z][\w.,\s<>?]*>\(/.test(s.slice(i, i + 80))) {
82 // A generic call: `@Html.Partial<Foo>(…)`.
83 i = s.indexOf('(', i);
84 } else if ((c === '.' || (c === '?' && s[i + 1] === '.')) && /[A-Za-z_]/.test(s[i + (c === '.' ? 1 : 2)] ?? '')) {
85 i += c === '.' ? 1 : 2;
86 const member = /^\w+/.exec(s.slice(i, i + 128));
87 i += member?.[0].length ?? 0;
88 } else {
89 return i;
90 }
91 }
92}
93
94/** Where the `</text>` closing the `<text>` at `open` starts, nested ones counted; -1 if none before `to`. */
95function closingText(s: string, open: number, to: number): number {

Callers 1

blankRazorFunction · 0.85

Calls 2

pastBracketFunction · 0.85
execMethod · 0.65

Tested by

no test coverage detected