* Resolve a symbol by name using indexed queries instead of scanning all files.
( name: string, kinds: Set<string>, preferredDirPatterns: string[], context: ResolutionContext, )
| 281 | * Resolve a symbol by name using indexed queries instead of scanning all files. |
| 282 | */ |
| 283 | function resolveByNameAndKind( |
| 284 | name: string, |
| 285 | kinds: Set<string>, |
| 286 | preferredDirPatterns: string[], |
| 287 | context: ResolutionContext, |
| 288 | ): string | null { |
| 289 | const candidates = context.getNodesByName(name); |
| 290 | if (candidates.length === 0) return null; |
| 291 | |
| 292 | const kindFiltered = candidates.filter((n) => kinds.has(n.kind)); |
| 293 | if (kindFiltered.length === 0) return null; |
| 294 | |
| 295 | // Prefer candidates in framework-conventional directories |
| 296 | const preferred = kindFiltered.filter((n) => |
| 297 | preferredDirPatterns.some((d) => n.filePath.includes(d)) |
| 298 | ); |
| 299 | |
| 300 | if (preferred.length > 0) return preferred[0]!.id; |
| 301 | |
| 302 | // Fall back to any match |
| 303 | return kindFiltered[0]!.id; |
| 304 | } |
| 305 | |
| 306 | interface ModuleResolution { |
| 307 | targetId: string; |
no test coverage detected