Port extraction quality improvements from PR #15

- Fix arrow function extraction: explicitly call extractFunction() for
  arrow functions/function expressions in variable declarations instead
  of silently skipping them (all 6 arrow function tests now pass)
- Best-candidate resolution: collect candidates from all strategies and
  return highest confidence match instead of first match
- Fix graph traversal 'both' direction: correctly determine next node
  for mixed incoming/outgoing edges in BFS and DFS

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Colby McHenry
2026-02-09 23:55:00 -06:00
co-authored by Claude Opus 4.6
parent d80900f653
commit 94c8d5ccaa
3 changed files with 23 additions and 9 deletions
+14 -5
View File
@@ -246,27 +246,36 @@ export class ReferenceResolver {
return null;
}
// Strategy 1: Try framework-specific resolution first
const candidates: ResolvedRef[] = [];
// Strategy 1: Try framework-specific resolution
for (const framework of this.frameworks) {
const result = framework.resolve(ref, this.context);
if (result) {
return result;
if (result.confidence >= 0.9) return result; // High confidence, return immediately
candidates.push(result);
}
}
// Strategy 2: Try import-based resolution
const importResult = resolveViaImport(ref, this.context);
if (importResult) {
return importResult;
if (importResult.confidence >= 0.9) return importResult;
candidates.push(importResult);
}
// Strategy 3: Try name matching
const nameResult = matchReference(ref, this.context);
if (nameResult) {
return nameResult;
candidates.push(nameResult);
}
return null;
if (candidates.length === 0) return null;
// Return highest confidence candidate
return candidates.reduce((best, curr) =>
curr.confidence > best.confidence ? curr : best
);
}
/**