| 82 | } |
| 83 | |
| 84 | function classify(node: Node, needle: string): MatchKind | null { |
| 85 | const name = node.name.toLowerCase(); |
| 86 | if (name === needle) return 'exact'; |
| 87 | if (name.startsWith(needle)) return 'prefix'; |
| 88 | if (name.includes(needle)) return 'substring'; |
| 89 | if (node.qualifiedName.toLowerCase().includes(needle)) return 'qualified'; |
| 90 | if (node.filePath.toLowerCase().replace(/\\/g, '/').includes(needle)) return 'file'; |
| 91 | return null; |
| 92 | } |
| 93 | |
| 94 | export function buildSearch(cg: CodeGraph, query: URLSearchParams): unknown { |
| 95 | const raw = optionalTextParam(query, 'q'); |