Interface Analysis.Hooks
- All Known Implementing Classes:
ConstructionValidation
,EditClassOccurenceAnalysis
,EditClassValidation
,ExampleFinder
,FilterAnalysis
,LineGraphExportAnalysis
,PreprocessingAnalysis
,StatisticsAnalysis
,ViewAnalysis
- Enclosing class:
Analysis
VariationDiff
s.
In general the hooks of different Hook
instances are called in sequence according
to the order specified in Analysis(java.lang.String, java.util.List<org.variantsync.diffdetective.analysis.Analysis.Hooks>, org.variantsync.diffdetective.datasets.Repository, java.nio.file.Path)
(except end hooks). Hooks are separated
into two categories: phases and events.
A phase consists of two hooks with the prefix begin
and end
. It is
guaranteed that the end hook is called if and only if the begin hook was called, even in the
presence of exceptions, so they are safe to use for resource management. For this purpose,
end hooks are called in reverse order as specified in Analysis(java.lang.String, java.util.List<org.variantsync.diffdetective.analysis.Analysis.Hooks>, org.variantsync.diffdetective.datasets.Repository, java.nio.file.Path)
.
Phases can be called an arbitrary number of times but are nested in the following order (from outer to inner):
- batch
- commit
- patch
An analysis implementing Hooks
can perform various actions during each hook. This
includes the creation
and modification
of analysis results
, modifying their internal state, performing IO operations and throwing
exceptions. In contrast, the only analysis state hooks are allowed to modify is the result
of an Analysis
. All other state (e.g. Analysis.getCurrentCommit()
)
must not be modified. Care must be taken to avoid the reliance of the internal state on a
specific commit batch being processed as only the results
of each commit
batch are merged and returned by Analysis.forEachCommit(java.util.function.Supplier<org.variantsync.diffdetective.analysis.Analysis>)
.
Hooks that return a boolean
are called filter hooks and can, in addition to the
above, skip any further processing in the current phase (including following inner phases) by
returning false
. If a hook starts skipping, any invocations of the same filter hook
of following Hook
instances won't be executed. Processing continues (after calling
missing end hooks of the current phase) in the next outer phase after the skipped phase.
Hooks without a begin
or end
prefix are events emitted during some
specified conditions. See their respective documentation for details.
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
analyzeVariationDiff
(Analysis analysis) The main hook for analyzing non-empty diff trees.default void
beginBatch
(Analysis analysis) default boolean
beginCommit
(Analysis analysis) default boolean
beginPatch
(Analysis analysis) default void
default void
default void
default void
initializeResults
(Analysis analysis) Initialization hook forAnalysis.getResult()
.default void
onFailedCommit
(Analysis analysis) Signals a parsing failure of all patches in the current commit.default void
onFailedParse
(Analysis analysis) Signals a parsing failure of some patch in the current commit.default boolean
onParsedCommit
(Analysis analysis) Signals the completion of the commit diff extraction.
-
Method Details
-
initializeResults
Initialization 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. -
beginBatch
- Throws:
Exception
-
beginCommit
- Throws:
Exception
-
onFailedCommit
Signals a parsing failure of all patches in the current commit. Called at most once during the commit phase. If this hook is calledonParsedCommit(org.variantsync.diffdetective.analysis.Analysis)
and the following patch phase invocations are skipped.- Throws:
Exception
-
onFailedParse
Signals a parsing failure of some patch in the current commit. Called at most once during the commit phase.- Throws:
Exception
-
onParsedCommit
Signals the completion of the commit diff extraction. Called exactly once during the commit phase before the patch phase begins.- Throws:
Exception
-
beginPatch
- Throws:
Exception
-
analyzeVariationDiff
The main hook for analyzing non-empty diff trees. Called at most once during the patch phase.- Throws:
Exception
-
endPatch
- Throws:
Exception
-
endCommit
- Throws:
Exception
-
endBatch
- Throws:
Exception
-