Class AbstractDiffContentCallback
- All Implemented Interfaces:
DiffContentCallback
DiffContentCallback that provides no-op implementations for all methods.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidofferThreads(Stream<CommentThread> threads) Offersthreadsfor any comments which should be included in the diff to the callback.voidCalled to indicate a binary file differs.voidonDiffEnd(boolean truncated) Called upon reaching the end of the current overall diff, indicating no more changes exist for the current source/destination pair.voidonDiffStart(Path src, Path dst) Called to mark the start of an overall diff.voidonEnd(DiffSummary summary) Called after the finalDiffContentCallback.onDiffEnd(boolean), after all diffs have been streamed.voidonHunkEnd(boolean truncated) Called upon reaching the end of a hunk of segments within the current overall diff.voidonHunkStart(int srcLine, int srcSpan, int dstLine, int dstSpan, String context) Called to mark the start of a new hunk within the current overall diff, containing one or more contiguous segments of lines anchored at the provided line numbers in the source and destination files.voidonSegmentEnd(boolean truncated) Called upon reaching the end of a segment within the current hunk, where a segment may end either because lines with a different type were encountered or because there are no more contiguous lines in the hunk.voidonSegmentLine(String line, ConflictMarker marker, boolean truncated) Called to process a line within the current segment.voidCalled to mark the start of a new segment within the current hunk, containing one or more contiguous lines which all share the sametype.voidonStart(DiffContext context) Called before the firstDiffContentCallback.onDiffStart(Path, Path).
-
Constructor Details
-
AbstractDiffContentCallback
public AbstractDiffContentCallback()
-
-
Method Details
-
offerThreads
Description copied from interface:DiffContentCallbackOffersthreadsfor any comments which should be included in the diff to the callback. Threads with bothFileandlineanchors may both be included in the provided stream.Note: If this method is going to be invoked, it will always be invoked before the first invocation of
DiffContentCallback.onDiffStart(Path, Path). This method will be called at most once. If multiple diffs are going to be output to the callback, thepathsof the anchors may reference any of the files whose diffs will follow. Reconciling anchors to diffs is left to the implementation.- Specified by:
offerThreadsin interfaceDiffContentCallback- Parameters:
threads- a stream of zero or more threads describing comments within the diff or diffs that will be streamed to the callback. It can only be consumed once- Throws:
IOException- may be thrown by implementations which perform I/O.- Since:
- 5.0
-
onBinary
Description copied from interface:DiffContentCallbackCalled to indicate a binary file differs. The exact differences cannot be effectively conveyed, however, so no hunks/segments will be provided for binary files.- Specified by:
onBinaryin interfaceDiffContentCallback- Parameters:
src- the source binary filedst- the destination binary file- Throws:
IOException- may be thrown by implementations which perform I/O.
-
onDiffEnd
Description copied from interface:DiffContentCallbackCalled upon reaching the end of the current overall diff, indicating no more changes exist for the current source/destination pair.- Specified by:
onDiffEndin interfaceDiffContentCallback- Parameters:
truncated-trueif any segment or hunk in the diff had to be truncated; otherwise,false- Throws:
IOException- may be thrown by implementations which perform I/O.
-
onDiffStart
Description copied from interface:DiffContentCallbackCalled to mark the start of an overall diff. The source and destination paths being compared, relative to their containingrepository, are provided.- Specified by:
onDiffStartin interfaceDiffContentCallback- Parameters:
src- the source file being compareddst- the destination file being compared- Throws:
IOException- may be thrown by implementations which perform I/O.
-
onEnd
Description copied from interface:DiffContentCallbackCalled after the finalDiffContentCallback.onDiffEnd(boolean), after all diffs have been streamed.- Specified by:
onEndin interfaceDiffContentCallback- Parameters:
summary- ignored- Throws:
IOException- may be thrown by derived classes
-
onHunkEnd
Description copied from interface:DiffContentCallbackCalled upon reaching the end of a hunk of segments within the current overall diff.- Specified by:
onHunkEndin interfaceDiffContentCallback- Parameters:
truncated-trueif any segment in the hunk had to be truncated; otherwise,false- Throws:
IOException- may be thrown by implementations which perform I/O.
-
onHunkStart
public void onHunkStart(int srcLine, int srcSpan, int dstLine, int dstSpan, @Nullable String context) throws IOException Description copied from interface:DiffContentCallbackCalled to mark the start of a new hunk within the current overall diff, containing one or more contiguous segments of lines anchored at the provided line numbers in the source and destination files.- Specified by:
onHunkStartin interfaceDiffContentCallback- Parameters:
srcLine- the line in the source file at which the hunk startssrcSpan- the number of lines spanned by this hunk in the source filedstLine- the line in the destination file at which the hunk startsdstSpan- the number of lines spanned by this hunk in the destination filecontext- an optional context, such as a method or class name, for the hunk's lines- Throws:
IOException- may be thrown by derived classes- Since:
- 5.5
-
onSegmentEnd
Description copied from interface:DiffContentCallbackCalled upon reaching the end of a segment within the current hunk, where a segment may end either because lines with a different type were encountered or because there are no more contiguous lines in the hunk.Note: Internal restrictions may prevent streaming full segments if they are overly large. For example, if a new file containing tens of thousands of lines is added (or an existing file of such size is deleted), the resulting segment may be truncated.
- Specified by:
onSegmentEndin interfaceDiffContentCallback- Parameters:
truncated-trueif the overall segment exceeded the maximum allowed lines, indicating one or more lines were omitted from the segment; otherwisefalseto indicate all lines were sent- Throws:
IOException- may be thrown by implementations which perform I/O.
-
onSegmentLine
public void onSegmentLine(@Nonnull String line, @Nullable ConflictMarker marker, boolean truncated) throws IOException Description copied from interface:DiffContentCallbackCalled to process a line within the current segment.Pull requestdiffs may contain conflicts, if the pull request cannot be merged cleanly. Themarkerconveys this information.null: The line is not conflictedConflictMarker.MARKER: The line is a conflict markerConflictMarker.OURS: The line is conflicting, and is present in the merge targetConflictMarker.THEIRS: The line is conflicting, and is present in the merge source
Note: Internal restrictions may prevent receiving the full line if it contains too many characters. When this happens
truncatedwill be set totrueto indicate the line is not complete.- Specified by:
onSegmentLinein interfaceDiffContentCallback- Parameters:
line- a single line of contentmarker- indicates whether the line is conflicted and, if it is, which side of the conflict it's ontruncated-trueif the line exceeded the maximum allowed length and was truncated; otherwise,falseto indicate the line is complete- Throws:
IOException- may be thrown by implementations which perform I/O.
-
onSegmentStart
Description copied from interface:DiffContentCallbackCalled to mark the start of a new segment within the current hunk, containing one or more contiguous lines which all share the sametype.- Specified by:
onSegmentStartin interfaceDiffContentCallback- Parameters:
type- the shared type for all lines in the new segment- Throws:
IOException- may be thrown by implementations which perform I/O.
-
onStart
Description copied from interface:DiffContentCallbackCalled before the firstDiffContentCallback.onDiffStart(Path, Path).- Specified by:
onStartin interfaceDiffContentCallback- Parameters:
context- ignored- Throws:
IOException- may be thrown by derived classes
-