HighlightedDiff class final

Syntax colors for both sides of a FileDiff.

Removed lines are highlighted as part of the old file and the other lines as part of the new one. With the full texts, both files are tokenized from the top, so highlighting is exact and costs time in proportion to the files, not the hunks. A parsed patch only has its hunks, so each hunk is tokenized from a fresh state, which is what GitHub does too. A construct that opens before a hunk, such as a block comment, may be colored wrongly inside it.

Constructors

HighlightedDiff.of(FileDiff diff, {required Highlighter highlighter, required SyntaxTheme theme, String? language, Duration? budget})
Highlights diff. The language comes from language if given, otherwise from the file extension. Unknown languages stay plain.
factory

Properties

hashCode → int
The hash code for this object.
no setterinherited
isComplete → bool
Whether every line has its colors.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

newLine(int number) → List<ThemedToken>
Tokens for line number of the new file. Lines outside the hunks are only available when the diff has the full texts.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
oldLine(int number) → List<ThemedToken>
Tokens for line number of the old file. Lines outside the hunks are only available when the diff has the full texts.
segmentsFor(DiffLine line, [WordChanges? words]) → List<DiffSegment>
line as styled segments, ready to paint. With words, the segments are split where the line's changed words start and end, and those are marked DiffSegment.changed. A line without tokens, such as an expanded line of a parsed patch, is one plain segment.
tokenize({Duration? budget}) → bool
Continues highlighting that HighlightedDiff.of left unfinished, the new file first, for at most budget. Returns isComplete.
tokensFor(DiffLine line) → List<ThemedToken>
Tokens for a line of the diff: removed lines from the old file, added and context lines from the new one.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited