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

Function matchingBracket

src/resolution/type-parameters.ts:306–320  ·  view source on GitHub ↗

* The bracket closing the one at `open`. A `[…]` list counts only square * brackets and parentheses — Scala's bounds `B >: A` and `A <: AnyRef` are not * angle brackets — and a `<…>` list skips the `->` / `=>` inside its bounds.

(text: string, open: number)

Source from the content-addressed store, hash-verified

304 * angle brackets — and a `<…>` list skips the `->` / `=>` inside its bounds.
305 */
306function matchingBracket(text: string, open: number): number {
307 const angle = text[open] === '<';
308 const closer = angle ? '>' : text[open] === '[' ? ']' : ')';
309 let depth = 0;
310 for (let i = open; i < text.length; i++) {
311 const c = text[i]!;
312 if (c === '{' || c === ';') return -1;
313 if (isOpener(c, angle)) depth++;
314 else if (isCloser(c, angle, text[i - 1])) {
315 depth--;
316 if (depth === 0) return c === closer ? i : -1;
317 }
318 }
319 return -1;
320}
321
322function splitTopLevel(inner: string, angle: boolean): string[] {
323 const out: string[] = [];

Callers 2

declaredValueParametersFunction · 0.70
collectFunction · 0.70

Calls 2

isOpenerFunction · 0.85
isCloserFunction · 0.85

Tested by

no test coverage detected