feat: Enhance symbol search with co-location boosting and receiver type support

Improves search accuracy by boosting results when multiple query symbols appear in the same file, addressing cases where common names like "run" return too many results. Adds Go method receiver type extraction to qualified names for better searchability (e.g., "scrapeLoop.run"). Optimizes database queries with two-pass approach to handle distinctive vs common symbol names efficiently.
This commit is contained in:
Colby McHenry
2026-04-06 11:16:56 -05:00
parent d256af3a23
commit 7a3afc9124
16 changed files with 466 additions and 877 deletions
+9 -31
View File
@@ -201,47 +201,25 @@ function isPascalCase(str: string): boolean {
}
/**
* Resolve a Svelte component reference to its .svelte file
* Resolve a Svelte component reference using name-based lookup
*/
function resolveComponent(
name: string,
fromFile: string,
context: ResolutionContext
): string | null {
// Look for matching .svelte files
const allFiles = context.getAllFiles();
const svelteFiles = allFiles.filter((f) => f.endsWith('.svelte'));
// Look for component nodes by name
const candidates = context.getNodesByName(name);
const components = candidates.filter((n) => n.kind === 'component');
// Check for exact name match (Button -> Button.svelte)
for (const file of svelteFiles) {
const fileName = file.split(/[/\\]/).pop() || '';
const componentName = fileName.replace(/\.svelte$/, '');
if (componentName === name) {
const nodes = context.getNodesInFile(file);
const component = nodes.find((n) => n.kind === 'component' && n.name === name);
if (component) {
return component.id;
}
}
}
if (components.length === 0) return null;
// Check same directory first for better specificity
// Prefer same directory
const fromDir = fromFile.substring(0, fromFile.lastIndexOf('/'));
for (const file of svelteFiles) {
if (file.startsWith(fromDir)) {
const fileName = file.split(/[/\\]/).pop() || '';
const componentName = fileName.replace(/\.svelte$/, '');
if (componentName === name) {
const nodes = context.getNodesInFile(file);
const component = nodes.find((n) => n.kind === 'component');
if (component) {
return component.id;
}
}
}
}
const sameDir = components.filter((n) => n.filePath.startsWith(fromDir));
if (sameDir.length > 0) return sameDir[0]!.id;
return null;
return components[0]!.id;
}
/**