feat(generator): DiffTraverser/DiffVisitor for paired tree comparison (C36)#1139
Open
jsenko wants to merge 2 commits into
Open
feat(generator): DiffTraverser/DiffVisitor for paired tree comparison (C36)#1139jsenko wants to merge 2 commits into
jsenko wants to merge 2 commits into
Conversation
…36 Phase 1) Base classes for paired tree traversal: - CollectionDiff with Entry/MatchedPair for collection comparison results - PairingStrategy interface with KeyPairingStrategy (maps) and IndexPairingStrategy (lists) - DiffVisitor abstract base with field-level diff methods and strategy selection callback - AbstractDiffTraverser with shared diffMap/diffList/diffEntityField helpers and auto-recursion into matched pairs
New CreateDiffTraversersStage generates per-spec-version diff traversers that walk two trees in parallel, dispatching to DiffVisitor methods: - diffPrimitive for primitive fields - diffEntityField for entity fields (auto-recurses) - diffUnionField for union fields - diffMap for map fields (pairs by key, auto-recurses matches) - diffList for list fields (pairs by index, auto-recurses matches) Registered in pipeline after CreateTraversersStage. Base classes registered in LoadBaseClassesStage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New infrastructure for paired tree traversal — walks two trees of the same spec version in parallel, dispatching field-level diffs to a pluggable DiffVisitor.
Base classes (
visitors/diff/)DiffVisitor— abstract visitor with methods for each field type:diffPrimitive,diffEntity,diffUnion,diffList,diffMap. Strategy selection viagetPairingStrategy(propertyName).AbstractDiffTraverser— shareddiffMap/diffList/diffEntityFieldhelpers with auto-recursion into matched pairs.CollectionDiff<K,V>— diff result with added/removed/matched entries.PairingStrategy<K,V>— pluggable collection pairing. Built-in:KeyPairingStrategy(maps),IndexPairingStrategy(lists).Generated per spec version
CreateDiffTraversersStage— generatesXxxDiffTraverserper spec version (e.g.,JD7DiffTraverser), following the same entity-property iteration asCreateTraversersStage.traverseXxx(original, updated)method that dispatches to the visitor.traverseNode(original, updated)dispatches byinstanceofto the correct entity method.Example generated output
Context
C36 Phase 1-2 in #1042. Phase 3 (compat checker migration) will be a follow-up.
Test plan