Class DefaultContextProvider
java.lang.Object
org.variantsync.studies.evolution.simulation.diff.splitting.DefaultContextProvider
- All Implemented Interfaces:
IContextProvider
A context provider is responsible for providing the correct context whenever lines in a patch are filtered.
This becomes necessary, because filtering changes from a patch results in a new context for adjacent changes that have
not been filtered. The DefaultContextProvider determines a new context based on the filters that are used to adjust
a patch.
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultContextProvider
(Path rootDir) DefaultContextProvider
(Path rootDir, int contextSize) -
Method Summary
Modifier and TypeMethodDescriptionleadingContext
(ILineFilter lineFilter, FileDiff fileDiff, int index) Determine the lines in the leading context of a change and return them.trailingContext
(ILineFilter lineFilter, FileDiff fileDiff, int index) Determine the lines in the trailing context of a change and return them.
-
Constructor Details
-
DefaultContextProvider
- Parameters:
rootDir
- The working directory containing the files for which a context is to be determined
-
DefaultContextProvider
- Parameters:
rootDir
- The working directory containing the files for which a context is to be determinedcontextSize
- The size of the provided context (i.e., number of leading/trailing lines)
-
-
Method Details
-
leadingContext
Description copied from interface:IContextProvider
Determine the lines in the leading context of a change and return them. The context is determined based on a provided filter that may remove lines from the context.- Specified by:
leadingContext
in interfaceIContextProvider
- Parameters:
lineFilter
- The line filter that has been used to adjust the patch for which the context is providedfileDiff
- The file diff containing the hunks for which a new context is to be determinedindex
- The line number of the change for which a context is to be provided- Returns:
- The leading context for the change
-
trailingContext
Description copied from interface:IContextProvider
Determine the lines in the trailing context of a change and return them. The context is determined based on a provided filter that may remove lines from the context.- Specified by:
trailingContext
in interfaceIContextProvider
- Parameters:
lineFilter
- The line filter that has been used to adjust the patch for which the context is providedfileDiff
- The file diff containing the hunks for which a new context is to be determinedindex
- The line number of the change for which a context is to be provided- Returns:
- The trailing context for the change
-