A path at `at` — `Commands::Build`, `Self::A` — as its segments and the offset after it.
(code: string, at: number)
| 272 | |
| 273 | /** A path at `at` — `Commands::Build`, `Self::A` — as its segments and the offset after it. */ |
| 274 | function readPath(code: string, at: number): { segments: string[]; end: number } { |
| 275 | const segments: string[] = []; |
| 276 | let p = at; |
| 277 | for (;;) { |
| 278 | const id = identAt(code, p); |
| 279 | if (!id) break; |
| 280 | segments.push(id); |
| 281 | p += id.length; |
| 282 | let q = skipSpace(code, p); |
| 283 | if (!code.startsWith('::', q)) break; |
| 284 | q = skipSpace(code, q + 2); |
| 285 | // A turbofish: `Foo::<T>::Bar`, `Vec::<u8>`. |
| 286 | if (code[q] === '<') { |
| 287 | const end = angleClose(code, q); |
| 288 | if (end < 0) break; |
| 289 | p = end + 1; |
| 290 | q = skipSpace(code, p); |
| 291 | if (!code.startsWith('::', q)) break; |
| 292 | q = skipSpace(code, q + 2); |
| 293 | } |
| 294 | p = q; |
| 295 | } |
| 296 | return { segments, end: p }; |
| 297 | } |
| 298 | |
| 299 | type Emit = (name: string, at: number, site: RustPatternSite | undefined) => void; |
| 300 |
no test coverage detected