compareLines method
Compares two iterables of lines from source
to target
.
The optional arguments sourceLabel
and targetLabel
are used by some
differs to print additional information about where the data is coming
from, i.e. the filename and the last modification date.
Implementation
@override
Iterable<String> compareLines(
Iterable<String> source, Iterable<String> target,
{String? sourceLabel, String? targetLabel}) sync* {
final lineMatcher =
SequenceMatcher(source: source, target: target, isJunk: lineJunk);
for (final operation in lineMatcher.operations) {
switch (operation.type) {
case OperationType.replace:
yield* _replace(source, operation.sourceStart, operation.sourceEnd,
target, operation.targetStart, operation.targetEnd);
case OperationType.delete:
yield* _dump(
deleteLine, source, operation.sourceStart, operation.sourceEnd);
case OperationType.insert:
yield* _dump(
insertLine, target, operation.targetStart, operation.targetEnd);
case OperationType.equal:
yield* _dump(
equalLine, source, operation.sourceStart, operation.sourceEnd);
}
}
}