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

Function attributeEnd

src/extraction/languages/pascal-preparse.ts:244–266  ·  view source on GitHub ↗

* The index after the `]` closing the attribute group whose `[` is at `i`, * or -1 when the group doesn't close the way an attribute does: nested * brackets and parentheses balance, strings and comments are skipped, and an * attribute's arguments hold no `;`.

(s: string, i: number)

Source from the content-addressed store, hash-verified

242 * attribute's arguments hold no `;`.
243 */
244function attributeEnd(s: string, i: number): number {
245 const limit = Math.min(s.length, i + MAX_ATTRIBUTE_LENGTH);
246 let depth = 0;
247 let j = i;
248 while (j < limit) {
249 const k = commentOrStringEnd(s, j);
250 if (k >= 0) {
251 j = k;
252 continue;
253 }
254 const c = s.charCodeAt(j);
255 if (c === CH_LBRACKET || c === CH_LPAREN) {
256 depth++;
257 } else if (c === CH_RBRACKET || c === CH_RPAREN) {
258 depth--;
259 if (depth === 0) return c === CH_RBRACKET ? j + 1 : -1;
260 } else if (c === CH_SEMI) {
261 return -1;
262 }
263 j++;
264 }
265 return -1;
266}
267
268/**
269 * The index after a routine's name — `Name`, `TFoo.Bar`, `TFoo<T>.Bar<U>`,

Callers 1

scanParameterListFunction · 0.85

Calls 1

commentOrStringEndFunction · 0.85

Tested by

no test coverage detected