Class JPPDiffLineFormulaExtractor

java.lang.Object
org.variantsync.diffdetective.feature.AbstractingFormulaExtractor
org.variantsync.diffdetective.feature.jpp.JPPDiffLineFormulaExtractor
All Implemented Interfaces:
DiffLineFormulaExtractor

public class JPPDiffLineFormulaExtractor extends AbstractingFormulaExtractor
Extracts the expression from a JavaPP (Java PreProcessor) statement . For example, given the annotation "//#if defined(A) || B()", the extractor would extract "DEFINED_A || B". The extractor detects if and elif annotations (other annotations do not have expressions). The given JPP statement might also be a line in a diff (i.e., preceeded by a - or +).
Author:
Alexander Schultheiß
  • Field Details

    • JPP_ANNOTATION_REGEX

      private static final String JPP_ANNOTATION_REGEX
      See Also:
    • JPP_ANNOTATION_PATTERN

      private static final Pattern JPP_ANNOTATION_PATTERN
  • Constructor Details

    • JPPDiffLineFormulaExtractor

      public JPPDiffLineFormulaExtractor()
  • Method Details

    • abstractFormula

      protected String abstractFormula(String formula)
      Abstract the given formula.

      First, the visitor uses ANTLR to parse the formula into a parse tree gives the tree to a AbstractingJPPExpressionVisitor. The visitor traverses the tree starting from the root, searching for subtrees that must be abstracted. If such a subtree is found, the visitor abstracts the part of the formula in the subtree.

      Specified by:
      abstractFormula in class AbstractingFormulaExtractor
      Parameters:
      formula - that is to be abstracted
      Returns:
      the abstracted formula