Class ExampleFinder
java.lang.Object
org.variantsync.diffdetective.examplesearch.ExampleFinder
- All Implemented Interfaces:
Analysis.Hooks
Helper class to find suitable running examples.
An example finder inspects each VariationDiff, checks some requirements relevant for the
desired running example and writes candidates to a file and renders them.
An example finder should be side-effect free (i.e., it does not alter or transform the given VariationDiff, just observes it).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final PatchDiffRendererstatic final RenderOptions<DiffLinesLabel> Default render options for exporting example candidates.private final ExplainedFilter<VariationDiff<? extends DiffLinesLabel>> -
Constructor Summary
ConstructorsConstructorDescriptionExampleFinder(ExplainedFilter<VariationDiff<? extends DiffLinesLabel>> isGoodExample, VariationDiffRenderer renderer) Creates a new ExampleFinder. -
Method Summary
Modifier and TypeMethodDescriptionbooleananalyzeVariationDiff(Analysis analysis) The main hook for analyzing non-empty diff trees.private booleancheckIfExample(Analysis analysis, String localDiff) private voidexportExample(Analysis analysis, String tdiff, VariationDiff<DiffLinesLabel> vdiff, Path outputDir) (package private) static StringgetDiff(VariationDiff<?> tree) voidinitializeResults(Analysis analysis) Initialization hook forAnalysis.getResult().Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.variantsync.diffdetective.analysis.Analysis.Hooks
beginBatch, beginCommit, beginPatch, endBatch, endCommit, endPatch, onFailedCommit, onFailedParse, onParsedCommit
-
Field Details
-
ExportOptions
Default render options for exporting example candidates. -
isGoodExample
-
exampleExport
-
-
Constructor Details
-
ExampleFinder
public ExampleFinder(ExplainedFilter<VariationDiff<? extends DiffLinesLabel>> isGoodExample, VariationDiffRenderer renderer) Creates a new ExampleFinder.- Parameters:
isGoodExample- Function that decides whether a VariationDiff is an example candidate or not. Should returnOptional.empty()when the given tree is not a good example and thus, should not be considered. Should return a VariationDiff when the given tree is a good example candidate and should be exported. The returned VariationDiff might be the exact same VariationDiff or a subtree (e.g., to only export a certain subtree that is relevant).renderer- The renderer to use for rendering example candidates.
-
-
Method Details
-
split
-
checkIfExample
-
initializeResults
Description copied from interface:Analysis.HooksInitialization hook forAnalysis.getResult(). All result types should be appended with a neutral value usingAnalysis.append(org.variantsync.diffdetective.analysis.AnalysisResult.ResultKey<T>, T). No other side effects should be performed during this methods as it might be called an arbitrary amount of times.- Specified by:
initializeResultsin interfaceAnalysis.Hooks
-
analyzeVariationDiff
Description copied from interface:Analysis.HooksThe main hook for analyzing non-empty diff trees. Called at most once during the patch phase.- Specified by:
analyzeVariationDiffin interfaceAnalysis.Hooks
-
exportExample
private void exportExample(Analysis analysis, String tdiff, VariationDiff<DiffLinesLabel> vdiff, Path outputDir) -
getDiff
-