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
+6 -2
View File
@@ -85,7 +85,9 @@ export class GraphTraverser {
const adjacentEdges = this.getAdjacentEdges(node.id, opts.direction, opts.edgeKinds);
for (const adjEdge of adjacentEdges) {
const nextNodeId = opts.direction === 'incoming' ? adjEdge.source : adjEdge.target;
// Determine next node: for 'both' direction, edges can be either
// incoming or outgoing, so pick whichever end is not the current node
const nextNodeId = adjEdge.source === node.id ? adjEdge.target : adjEdge.source;
if (visited.has(nextNodeId)) {
continue;
@@ -169,7 +171,9 @@ export class GraphTraverser {
const adjacentEdges = this.getAdjacentEdges(node.id, opts.direction, opts.edgeKinds);
for (const edge of adjacentEdges) {
const nextNodeId = opts.direction === 'incoming' ? edge.source : edge.target;
// Determine next node: for 'both' direction, edges can be either
// incoming or outgoing, so pick whichever end is not the current node
const nextNodeId = edge.source === node.id ? edge.target : edge.source;
if (visited.has(nextNodeId)) {
continue;