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
FieldsModifier and TypeFieldDescriptionprivate final List<Stack<DiffNode<DiffLinesLabel>>> private final List<Stack<DiffNode<DiffLinesLabel>>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleananyChildEdited(DiffNode<?> d) private static voidcollapseChain(Stack<DiffNode<DiffLinesLabel>> chain) private voidfinalize(Stack<DiffNode<DiffLinesLabel>> chain) private voidfindChains(VariationDiffTraversal<DiffLinesLabel> traversal, DiffNode<DiffLinesLabel> subtree) List<Class<? extends VariationDiffTransformer<DiffLinesLabel>>> Returns a list of dependencies to other transformers.private static booleanhasExactlyOneChild(DiffNode<?> d) private static booleaninChainTail(DiffNode<?> d) private static booleanprivate static booleanprivate static booleannoChildEdited(DiffNode<?> d) toString()voidtransform(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:VariationDiffTransformerReturns 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:
getDependenciesin interfaceVariationDiffTransformer<DiffLinesLabel>- Returns:
- List of types of which instances should be run before applying this transformation.
-
transform
Description copied from interface:VariationDiffTransformerApply a transformation to the given VariationDiff inplace. The given tree will be changed.- Specified by:
transformin 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
-