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

Function angleClose

src/resolution/rust-scopes.ts:206–216  ·  view source on GitHub ↗

The offset of the `>` closing the `<` at `at`, or -1. `->` and `=>` close nothing.

(code: string, at: number, limit = code.length)

Source from the content-addressed store, hash-verified

204
205/** The offset of the `>` closing the `<` at `at`, or -1. `->` and `=>` close nothing. */
206function angleClose(code: string, at: number, limit = code.length): number {
207 let depth = 0;
208 for (let i = at; i < limit; i++) {
209 const c = code[i];
210 if (c === '<') depth++;
211 else if (c === '>' && code[i - 1] !== '-' && code[i - 1] !== '=') {
212 if (--depth === 0) return i;
213 } else if (c === ';' || c === '{' || c === '}') return -1;
214 }
215 return -1;
216}
217
218/**
219 * Walk `code` from `from` to `to` over what lies outside brackets: `stop`

Callers 2

readPathFunction · 0.85
readRustScopesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected