Class CollapseNestedNonEditedAnnotations
java.lang.Object
org.variantsync.diffdetective.variation.diff.transform.CollapseNestedNonEditedAnnotations
- All Implemented Interfaces:
VariationDiffTransformer<DiffLinesLabel>
public class CollapseNestedNonEditedAnnotations
extends Object
implements VariationDiffTransformer<DiffLinesLabel>
Collapses chains of nested non-edited annotations.
Imagine a annotation node that is unchanged and has the same parent before and after the edit
that is again an unchanged annotation node that has the same parent before and after the edit,
and so on. Such chains
NON_IF -> NON_IF -> NON_IF -> ... -> NON_IF
can be collapsed
into a single unchanged annotation node with the formulas of all nodes combined (by AND).
This collapse is realized by this transformer.
Fun fact: We implemented this transformation because of the
wurmcoil edit in Marlin.- Author:
- Paul Bittner
-
Field Summary
Modifier and TypeFieldDescriptionprivate final List<Stack<DiffNode<DiffLinesLabel>>>
private final List<Stack<DiffNode<DiffLinesLabel>>>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static boolean
anyChildEdited
(DiffNode<?> d) private static void
collapseChain
(Stack<DiffNode<DiffLinesLabel>> chain) private void
finalize
(Stack<DiffNode<DiffLinesLabel>> chain) private void
findChains
(VariationDiffTraversal<DiffLinesLabel> traversal, DiffNode<DiffLinesLabel> subtree) List<Class<? extends VariationDiffTransformer<DiffLinesLabel>>>
Returns a list of dependencies to other transformers.private static boolean
hasExactlyOneChild
(DiffNode<?> d) private static boolean
inChainTail
(DiffNode<?> d) private static boolean
private static boolean
private static boolean
noChildEdited
(DiffNode<?> d) toString()
void
transform
(VariationDiff<DiffLinesLabel> variationDiff) Apply a transformation to the given VariationDiff inplace.
-
Field Details
-
chainCandidates
-
chains
-
-
Constructor Details
-
CollapseNestedNonEditedAnnotations
public CollapseNestedNonEditedAnnotations()
-
-
Method Details
-
getDependencies
Description copied from interface:VariationDiffTransformer
Returns a list of dependencies to other transformers. A transformer should only be run, if another transformation with the respective type was run for each type on the dependencies.- Specified by:
getDependencies
in interfaceVariationDiffTransformer<DiffLinesLabel>
- Returns:
- List of types of which instances should be run before applying this transformation.
-
transform
Description copied from interface:VariationDiffTransformer
Apply a transformation to the given VariationDiff inplace. The given tree will be changed.- Specified by:
transform
in interfaceVariationDiffTransformer<DiffLinesLabel>
- Parameters:
variationDiff
- The VariationDiff to transform.
-
finalize
-
findChains
private void findChains(VariationDiffTraversal<DiffLinesLabel> traversal, DiffNode<DiffLinesLabel> subtree) -
collapseChain
-
anyChildEdited
- Returns:
- True iff at least one child of was edited.
-
noChildEdited
- Returns:
- True iff no child of was edited.
-
hasExactlyOneChild
-
inChainTail
- Returns:
- True iff d is in the tail of a chain.
-
isHead
- Returns:
- True iff d is the head of a chain.
-
isEnd
- Returns:
- True iff d is the end of a chain and any chain ending at d has to end.
-
toString
-