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

Function closingBracket

src/resolution/pascal-scope.ts:1492–1505  ·  view source on GitHub ↗

The offset of the bracket that closes the one at `open` (`(`/`[`), or -1.

(text: string, open: number)

Source from the content-addressed store, hash-verified

1490
1491/** The offset of the bracket that closes the one at `open` (`(`/`[`), or -1. */
1492function closingBracket(text: string, open: number): number {
1493 let depth = 0;
1494 for (let i = open; i < text.length; i++) {
1495 const skip = triviaEnd(text, i);
1496 if (skip > i) {
1497 i = skip - 1;
1498 continue;
1499 }
1500 const c = text.charCodeAt(i);
1501 if (c === CH_LPAREN || c === CH_LBRACKET) depth++;
1502 else if ((c === CH_RPAREN || c === CH_RBRACKET) && --depth === 0) return i;
1503 }
1504 return -1;
1505}
1506
1507/** The links of a `with` subject (see SubjectLink), or null for any other expression. */
1508function subjectLinks(text: string): SubjectLink[] | null {

Callers 2

withSubjectTypeFunction · 0.70
subjectLinksFunction · 0.70

Calls 1

triviaEndFunction · 0.85

Tested by

no test coverage detected