Package org.eclipse.compare.patch
Class PatchBuilder
java.lang.Object
org.eclipse.compare.patch.PatchBuilder
Builder for creating IFilePatch2 and IHunk objects as well as building
relationship between them.
- Since:
- org.eclipse.compare.core 3.5
- Restriction:
- This class is not intended to be subclassed by clients.
- Restriction:
- This class is not intended to be instantiated by clients.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final char
Line prefix used to mark an added lines.static final char
Line prefix used to mark context lines.static final char
Line prefix used to mark an removed lines. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic IFilePatch2
addHunks
(IFilePatch2 filePatch, IHunk[] toAdd) Adds IHunks to a given IFilePatch2 and performs recalculation of all hunks' after positions.static IFilePatch2
createFilePatch
(IPath oldPath, long oldDate, IPath newPath, long newDate, IHunk[] hunks) Creates an IFilePatch2 instance and performs recalculation of all hunks' after positions.static IHunk
createHunk
(int start, String[] lines) Creates an IHunk instance.static IFilePatch2
removeHunks
(IFilePatch2 filePatch, IHunk[] toRemove) Removes IHunks from a given IFilePatch2 and performs recalculation of all hunks' after positions.
-
Field Details
-
CONTEXT_PREFIX
public static final char CONTEXT_PREFIXLine prefix used to mark context lines.- See Also:
-
ADDITION_PREFIX
public static final char ADDITION_PREFIXLine prefix used to mark an added lines.- See Also:
-
REMOVAL_PREFIX
public static final char REMOVAL_PREFIXLine prefix used to mark an removed lines.- See Also:
-
-
Constructor Details
-
PatchBuilder
public PatchBuilder()
-
-
Method Details
-
createHunk
Creates an IHunk instance.- Parameters:
start
- the start position in the before filelines
- content of the hunk. Each line starts with a control character. Their meaning is as follows:- '+': add the line
- '-': delete the line
- ' ': no change, context line
- Returns:
- IHunk instance
-
createFilePatch
public static IFilePatch2 createFilePatch(IPath oldPath, long oldDate, IPath newPath, long newDate, IHunk[] hunks) Creates an IFilePatch2 instance and performs recalculation of all hunks' after positions. Hunk's after position is position in the file state after applying a patch. It is affected by all the hunks that are to be applied before a given one. This recalculation is necessary to keep IFilePatch2's state coherent.- Parameters:
oldPath
- the path of the before state of the fileoldDate
- the timestamp of the before state of the file, see alsoIFilePatch2.DATE_UNKNOWN
newPath
- the path of the after state of the filenewDate
- the timestamp of the after state of the file, see alsoIFilePatch2.DATE_UNKNOWN
hunks
- a set of hunks to insert into IFilePatch2- Returns:
- IFilePatch2 instance
-
addHunks
Adds IHunks to a given IFilePatch2 and performs recalculation of all hunks' after positions. Hunk's after position is position in the file state after applying a patch. It is affected by all the hunks that are to be applied before a given one. This recalculation is necessary to keep IFilePatch2's state coherent.- Parameters:
filePatch
- a file patch to add hunks totoAdd
- a set of IHunks to add- Returns:
- newly created file patch with added hunks
-
removeHunks
Removes IHunks from a given IFilePatch2 and performs recalculation of all hunks' after positions. Hunk's after position is position in the file state after applying a patch. It is affected by all the hunks that are to be applied before a given one. This recalculation is necessary to keep IFilePatch2's state coherent.- Parameters:
filePatch
- a file patch to add hunks totoRemove
- a set of IHunks to add- Returns:
- newly created file patch with removed hunks
-