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

Function attributeEnd

src/extraction/languages/pascal-preparse.ts:249–271  ·  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

247 * attribute's arguments hold no `;`.
248 */
249function attributeEnd(s: string, i: number): number {
250 const limit = Math.min(s.length, i + MAX_ATTRIBUTE_LENGTH);
251 let depth = 0;
252 let j = i;
253 while (j < limit) {
254 const k = commentOrStringEnd(s, j);
255 if (k >= 0) {
256 j = k;
257 continue;
258 }
259 const c = s.charCodeAt(j);
260 if (c === CH_LBRACKET || c === CH_LPAREN) {
261 depth++;
262 } else if (c === CH_RBRACKET || c === CH_RPAREN) {
263 depth--;
264 if (depth === 0) return c === CH_RBRACKET ? j + 1 : -1;
265 } else if (c === CH_SEMI) {
266 return -1;
267 }
268 j++;
269 }
270 return -1;
271}
272
273/**
274 * 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