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

Function routineNameEnd

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

* The index after a routine's name — `Name`, `TFoo.Bar`, `TFoo .Bar `, * `Get ` — read from `i`, or `i` itself (trivia * skipped) when no name starts there (`procedure(…) of object`).

(s: string, i: number)

Source from the content-addressed store, hash-verified

271 * skipped) when no name starts there (`procedure(…) of object`).
272 */
273function routineNameEnd(s: string, i: number): number {
274 for (;;) {
275 i = skipTrivia(s, i);
276 if (!isIdentStart(s.charCodeAt(i))) return i;
277 i = wordEnd(s, i + 1);
278 let j = skipTrivia(s, i);
279 if (s.charCodeAt(j) === CH_LT) {
280 let depth = 0;
281 for (; j < s.length; j++) {
282 const c = s.charCodeAt(j);
283 if (c === CH_LT) {
284 depth++;
285 } else if (c === CH_GT) {
286 if (--depth === 0) {
287 j++;
288 break;
289 }
290 } else if (c === CH_SEMI || c === CH_LPAREN || c === CH_RPAREN || c === CH_LF) {
291 return i; // not a generic parameter list
292 }
293 }
294 i = j;
295 j = skipTrivia(s, i);
296 }
297 if (s.charCodeAt(j) !== CH_DOT) return i;
298 i = j + 1;
299 }
300}
301
302/**
303 * Walk the parameter list whose `(` is at `open`, pushing the `[from, to)`

Callers 1

preParsePascalFunction · 0.85

Calls 3

isIdentStartFunction · 0.85
skipTriviaFunction · 0.70
wordEndFunction · 0.70

Tested by

no test coverage detected