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

Function routineNameEnd

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

276 * skipped) when no name starts there (`procedure(…) of object`).
277 */
278function routineNameEnd(s: string, i: number): number {
279 for (;;) {
280 i = skipTrivia(s, i);
281 if (!isIdentStart(s.charCodeAt(i))) return i;
282 i = wordEnd(s, i + 1);
283 let j = skipTrivia(s, i);
284 if (s.charCodeAt(j) === CH_LT) {
285 let depth = 0;
286 for (; j < s.length; j++) {
287 const c = s.charCodeAt(j);
288 if (c === CH_LT) {
289 depth++;
290 } else if (c === CH_GT) {
291 if (--depth === 0) {
292 j++;
293 break;
294 }
295 } else if (c === CH_SEMI || c === CH_LPAREN || c === CH_RPAREN || c === CH_LF) {
296 return i; // not a generic parameter list
297 }
298 }
299 i = j;
300 j = skipTrivia(s, i);
301 }
302 if (s.charCodeAt(j) !== CH_DOT) return i;
303 i = j + 1;
304 }
305}
306
307/**
308 * 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