* The file's unresolved references, as line markers. * * Only plain identifiers survive. The resolver's samples are bookkeeping, and a * "name" that is really a whole arrow function or a receiver expression cannot * be matched to a token on the line — a marker that could not find its * identifi
( cg: CodeGraph, storedPath: string )
| 264 | * symbol. |
| 265 | */ |
| 266 | function buildOutsideRefs( |
| 267 | cg: CodeGraph, |
| 268 | storedPath: string |
| 269 | ): { items: WireFileOutsideRef[]; total: number } { |
| 270 | let raw; |
| 271 | try { |
| 272 | // Scanned, not capped at the display limit: `total` must be the real count |
| 273 | // and the identifier filter below cannot run in SQL. |
| 274 | raw = cg.getUnresolvedReferencesInFile(storedPath, MAX_FILE_OUTSIDE_SCAN); |
| 275 | } catch { |
| 276 | return { items: [], total: 0 }; |
| 277 | } |
| 278 | |
| 279 | const items: WireFileOutsideRef[] = []; |
| 280 | let total = 0; |
| 281 | for (const ref of raw) { |
| 282 | const name = lastSegment(ref.referenceName ?? ''); |
| 283 | if (!/^[A-Za-z_$][\w$]*$/.test(name)) continue; |
| 284 | if (!ref.line) continue; |
| 285 | total++; |
| 286 | if (items.length < MAX_FILE_OUTSIDE_REFS) { |
| 287 | items.push({ line: ref.line, col: ref.column ?? 0, name, kind: ref.referenceKind }); |
| 288 | } |
| 289 | } |
| 290 | return { items, total }; |
| 291 | } |
| 292 | |
| 293 | /** The trailing segment of a dotted name — what actually appears in the source. */ |
| 294 | function lastSegment(name: string): string { |
no test coverage detected