* Resolve a symbol by name using indexed queries instead of scanning all files.
( name: string, kinds: Set<string>, preferredDirPatterns: string[], context: ResolutionContext, )
| 528 | * Resolve a symbol by name using indexed queries instead of scanning all files. |
| 529 | */ |
| 530 | function resolveByNameAndKind( |
| 531 | name: string, |
| 532 | kinds: Set<string>, |
| 533 | preferredDirPatterns: string[], |
| 534 | context: ResolutionContext, |
| 535 | ): string | null { |
| 536 | const candidates = context.getNodesByName(name); |
| 537 | if (candidates.length === 0) return null; |
| 538 | |
| 539 | const kindFiltered = candidates.filter((n) => kinds.has(n.kind)); |
| 540 | if (kindFiltered.length === 0) return null; |
| 541 | |
| 542 | // Prefer candidates in framework-conventional directories |
| 543 | const preferred = kindFiltered.filter((n) => |
| 544 | preferredDirPatterns.some((d) => n.filePath.includes(d)) |
| 545 | ); |
| 546 | |
| 547 | if (preferred.length > 0) return preferred[0]!.id; |
| 548 | |
| 549 | // Fall back to any match |
| 550 | return kindFiltered[0]!.id; |
| 551 | } |
no test coverage detected