Class CPPDiffLineFormulaExtractor
java.lang.Object
org.variantsync.diffdetective.feature.AbstractingFormulaExtractor
org.variantsync.diffdetective.feature.cpp.CPPDiffLineFormulaExtractor
- All Implemented Interfaces:
DiffLineFormulaExtractor
- Direct Known Subclasses:
MarlinCPPDiffLineFormulaExtractor
Extracts the expression from a C preprocessor statement.
For example, given the annotation "#if defined(A) || B()", the extractor would extract
"A || B". The extractor detects if, ifdef, ifndef and elif annotations.
(Other annotations do not have expressions.)
The given pre-processor statement might also a line in a diff (i.e., preceeded by a - or +).
- Author:
- Paul Bittner, Sören Viegener, Benjamin Moosherr, Alexander Schultheiß
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
abstractFormula
(String formula) Abstract the given formula.extractFormula
(String line) Extracts the feature formula as a string from a macro line (possibly within a diff).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.variantsync.diffdetective.feature.DiffLineFormulaExtractor
resolveFeatureMacroFunctions
-
Field Details
-
CPP_ANNOTATION_REGEX
- See Also:
-
CPP_ANNOTATION_PATTERN
-
-
Constructor Details
-
CPPDiffLineFormulaExtractor
public CPPDiffLineFormulaExtractor()
-
-
Method Details
-
extractFormula
Extracts the feature formula as a string from a macro line (possibly within a diff).- Specified by:
extractFormula
in interfaceDiffLineFormulaExtractor
- Overrides:
extractFormula
in classAbstractingFormulaExtractor
- Parameters:
line
- The line of which to get the feature mapping- Returns:
- The feature mapping as a String of the given line
- Throws:
UnparseableFormulaException
-
abstractFormula
Abstract the given formula.First, the visitor uses ANTLR to parse the formula into a parse tree gives the tree to a
ControllingCExpressionVisitor
. The visitor traverses the tree starting from the root, searching for subtrees that must be abstracted. If such a subtree is found, the visitor calls anAbstractingCExpressionVisitor
to abstract the part of the formula in the subtree.- Specified by:
abstractFormula
in classAbstractingFormulaExtractor
- Parameters:
formula
- that is to be abstracted- Returns:
- the abstracted formula
-