Skip to content

feat(engine): reassign stolen containers during bottom-up matching - #69

Merged
HarshK97 merged 1 commit into
mainfrom
feature/contest-containers
Aug 8, 2026
Merged

feat(engine): reassign stolen containers during bottom-up matching#69
HarshK97 merged 1 commit into
mainfrom
feature/contest-containers

Conversation

@HarshK97

@HarshK97 HarshK97 commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Problem

  1. Bottom-up AST matching processes nodes from leaves up to the root. When a surrounding block like an if statement gets deleted, inner blocks inside the if can greedily claim the outer function body's container because they share common leaf statements.
  2. So the actual outer function body container is left unmapped, which forces the edit-script generator to emit a flood of spurious Move actions for all sibling statements.

What Changed

  • Added ContestContainers in internal/engine/bottom-up.go to reassign containers claimed by nested inner T1 nodes back to their proper outer T1 parent.
  • Updated Mapping.Remove in internal/engine/mapping.go so m.Pairs stays in sync when mappings are reassigned.
  • Called ContestContainers inside Match in internal/engine/matcher.go right after bottom-up matching finishes.
  • Updated golden test fixtures (go_gin_fix_lint, py_requests_refactor_prefer, and rust_tokio_test_tests_when) because the redundant move and delete/insert actions are now gone.

Visual Comparison

  • Example : tests/testdata/go_gin_fix_lint

Before

image

After

image

@HarshK97
HarshK97 merged commit 61a8400 into main Aug 8, 2026
13 checks passed
@HarshK97
HarshK97 deleted the feature/contest-containers branch August 8, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant