Class AbstractingFormulaExtractor
java.lang.Object
org.variantsync.diffdetective.feature.AbstractingFormulaExtractor
- All Implemented Interfaces:
DiffLineFormulaExtractor
- Direct Known Subclasses:
CPPDiffLineFormulaExtractor
,JPPDiffLineFormulaExtractor
public abstract class AbstractingFormulaExtractor
extends Object
implements DiffLineFormulaExtractor
AbstractingFormulaExtractor is an abstract class that extracts a formula from text containing a conditional annotation,
and then abstracts the formula using the custom
abstractFormula(String)
implementation of its subclass.
The extraction of a formula is controlled by a Pattern
with which an AbstractingFormulaExtractor is initialized.
The given text might also be a line in a diff (i.e., preceeded by a '-' or '+').
For example, given the annotation "#if defined(A) || B()", the extractor should extract the formula
"defined(A) || B". It would then hand this formula to the abstractFormula(String)
method for abstraction
(e.g., to substitute the 'defined(A)' macro call with 'DEFINED_A').
- Author:
- Paul Bittner, Sören Viegener, Benjamin Moosherr, Alexander Schultheiß
-
Field Summary
-
Constructor Summary
ConstructorDescriptionAbstractingFormulaExtractor
(Pattern annotationPattern) Initialize a new AbstractingFormulaExtractor object that uses the given Pattern to identify formulas in annotations. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract String
abstractFormula
(String formula) Abstract the given formula (e.g., by substituting parts of the formula with predefined String literals).extractFormula
(String text) Extracts the feature formula as a string from a piece of text (possibly within a diff) and abstracts it.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
-
annotationPattern
-
-
Constructor Details
-
AbstractingFormulaExtractor
Initialize a new AbstractingFormulaExtractor object that uses the given Pattern to identify formulas in annotations. SeeCPPDiffLineFormulaExtractor
for an example of how such a pattern could look like.- Parameters:
annotationPattern
- The pattern used for formula extraction
-
-
Method Details
-
extractFormula
Extracts the feature formula as a string from a piece of text (possibly within a diff) and abstracts it.- Specified by:
extractFormula
in interfaceDiffLineFormulaExtractor
- Parameters:
text
- The text of which to extract the formula- Returns:
- The extracted and abstracted formula
- Throws:
UnparseableFormulaException
-
abstractFormula
Abstract the given formula (e.g., by substituting parts of the formula with predefined String literals). SeeCPPDiffLineFormulaExtractor
for an example of how this could be done.- Parameters:
formula
- that is to be abstracted- Returns:
- the abstracted formula
-