Class GitPositionTransformer.Position
- Enclosing class:
- GitPositionTransformer
The term 'position' is our own invention. The underlying idea is that a Gerrit comment is at a specific position within the commit of a patchset. That position is defined by the attributes defined in this class.
The same thinking can be applied to diff hunks (= JGit edits). Each diff hunk maps a position in one commit (e.g. in the parent of the patchset) to a position in another commit (e.g. in the commit of the patchset).
We only refer to lines and not character offsets within the lines here as Git only works with line precision. In theory, we could do better in Gerrit as we also have intraline diffs. Incorporating those requires careful considerations, though.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
filePath()
Absolute file path.abstract Optional<GitPositionTransformer.Range>
Affected lines.shiftBy
(int amount) Creates a copy of thisPosition
whose range is shifted by the indicated amount.withFilePath
(String filePath) Creates a copy of thisPosition
whose file path is adjusted to the indicated value.Creates a copy of thisPosition
which doesn't refer to any specific lines.
-
Constructor Details
-
Position
public Position()
-
-
Method Details
-
filePath
Absolute file path. -
lineRange
Affected lines. An emptyOptional
indicates that this position does not refer to any specific lines (e.g. used for a file comment). -
shiftBy
Creates a copy of thisPosition
whose range is shifted by the indicated amount.Note: There's no guarantee that this method returns a new instance.
- Parameters:
amount
- number of lines to shift. Negative values mean moving the range up, positive values mean moving the range down.- Returns:
- a
Position
instance with the updated range
-
withoutLineRange
Creates a copy of thisPosition
which doesn't refer to any specific lines.Note: There's no guarantee that this method returns a new instance.
- Returns:
- a
Position
instance without a line range
-
withFilePath
Creates a copy of thisPosition
whose file path is adjusted to the indicated value.Note: There's no guarantee that this method returns a new instance.
- Parameters:
filePath
- the new file path to use- Returns:
- a
Position
instance with the indicated file path
-
builder
-