Class EliminateEmptyAlternatives

java.lang.Object
org.variantsync.diffdetective.variation.diff.transform.EliminateEmptyAlternatives
All Implemented Interfaces:
Transformer<VariationTree<DiffLinesLabel>>

public class EliminateEmptyAlternatives extends Object implements Transformer<VariationTree<DiffLinesLabel>>
This transformer simplifies annotations such that empty alternatives do not appear in choices. This means, that nestings without any siblings such as

 #if A
 #elif B
 #elif C
 #else
   foo
 #endif
 
will be simplified to

 #if !A && !B && !C
   foo
 #endif
 
Annotations without any children also get eliminated.
Author:
Paul Bittner
  • Constructor Details

    • EliminateEmptyAlternatives

      public EliminateEmptyAlternatives()
  • Method Details

    • updatedLabel

      private static DiffLinesLabel updatedLabel(DiffLinesLabel l, org.prop4j.Node formula)
      Creates a copy of the given label but where the formula is set to the given formula. This method also updates the text in the DiffLinesLabel accordingly so that the text is consistent with the formula. This method assumes that the label has at least one line of text, otherwise the given label could not have a formula.
    • elim

      private static void elim(VariationTreeNode<DiffLinesLabel> subtree)
    • transform

      public void transform(VariationTree<DiffLinesLabel> tree)
      Description copied from interface: Transformer
      Apply a transformation to the given Object inplace. The object will be changed.
      Specified by:
      transform in interface Transformer<VariationTree<DiffLinesLabel>>
      Parameters:
      tree - The T object to transform.