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

Function scanParameterList

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

* Walk the parameter list whose `(` is at `open`, pushing the `[from, to)` * range of each attribute group a parameter starts with — before or after its * modifier — onto `ranges`. Returns the index after the list's `)`.

(s: string, open: number, ranges: number[])

Source from the content-addressed store, hash-verified

310 * modifier — onto `ranges`. Returns the index after the list's `)`.
311 */
312function scanParameterList(s: string, open: number, ranges: number[]): number {
313 let depth = 0;
314 let i = open;
315 let atParameterStart = false;
316 while (i < s.length) {
317 if (atParameterStart) {
318 atParameterStart = false;
319 for (;;) {
320 i = skipTrivia(s, i);
321 const c = s.charCodeAt(i);
322 if (c === CH_LBRACKET) {
323 const end = attributeEnd(s, i);
324 if (end < 0) break;
325 ranges.push(i, end);
326 i = end;
327 } else if (isIdentStart(c)) {
328 const e = wordEnd(s, i + 1);
329 if (!MODIFIERS.has(s.slice(i, e).toLowerCase())) break;
330 i = e;
331 } else {
332 break;
333 }
334 }
335 continue;
336 }
337 const k = commentOrStringEnd(s, i);
338 if (k >= 0) {
339 i = k;
340 continue;
341 }
342 const c = s.charCodeAt(i);
343 if (c === CH_LPAREN || c === CH_LBRACKET) {
344 if (++depth === 1) atParameterStart = true;
345 } else if (c === CH_RPAREN || c === CH_RBRACKET) {
346 if (--depth <= 0) return i + 1;
347 } else if (c === CH_SEMI && depth === 1) {
348 atParameterStart = true;
349 }
350 i++;
351 }
352 return i;
353}
354
355/** The word starting at `i`, lowercased, or '' when no word starts there. */
356function lowerWordAt(s: string, i: number): string {

Callers 1

preParsePascalFunction · 0.85

Calls 7

attributeEndFunction · 0.85
isIdentStartFunction · 0.85
commentOrStringEndFunction · 0.85
pushMethod · 0.80
hasMethod · 0.80
skipTriviaFunction · 0.70
wordEndFunction · 0.70

Tested by

no test coverage detected