Class DefaultContextProvider

java.lang.Object
org.variantsync.studies.evolution.simulation.diff.splitting.DefaultContextProvider
All Implemented Interfaces:
IContextProvider

public class DefaultContextProvider extends Object implements 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 Details

    • DefaultContextProvider

      public DefaultContextProvider(Path rootDir)
      Parameters:
      rootDir - The working directory containing the files for which a context is to be determined
    • DefaultContextProvider

      public DefaultContextProvider(Path rootDir, int contextSize)
      Parameters:
      rootDir - The working directory containing the files for which a context is to be determined
      contextSize - The size of the provided context (i.e., number of leading/trailing lines)
  • Method Details

    • leadingContext

      public List<Line> leadingContext(ILineFilter lineFilter, FileDiff fileDiff, int index)
      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 interface IContextProvider
      Parameters:
      lineFilter - The line filter that has been used to adjust the patch for which the context is provided
      fileDiff - The file diff containing the hunks for which a new context is to be determined
      index - The line number of the change for which a context is to be provided
      Returns:
      The leading context for the change
    • trailingContext

      public List<Line> trailingContext(ILineFilter lineFilter, FileDiff fileDiff, int index)
      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 interface IContextProvider
      Parameters:
      lineFilter - The line filter that has been used to adjust the patch for which the context is provided
      fileDiff - The file diff containing the hunks for which a new context is to be determined
      index - The line number of the change for which a context is to be provided
      Returns:
      The trailing context for the change