@@ -46,10 +46,10 @@ class DiffSet {
4646
4747class Side <int > extends Enum <int > implements Comparable <Side <int >> {
4848 const Side (int val) : super (val);
49- static const Side Conflict = const Side (- 1 );
50- static const Side Left = const Side (0 );
51- static const Side Old = const Side (1 );
52- static const Side Right = const Side (2 );
49+ static const Side CONFLICT = const Side (- 1 );
50+ static const Side LEFT = const Side (0 );
51+ static const Side OLD = const Side (1 );
52+ static const Side RIGHT = const Side (2 );
5353
5454 @override
5555 /*int*/ compareTo (Side <int > other) {
@@ -101,15 +101,15 @@ class Diff3DigResult {
101101// Merge Result Objects
102102//
103103
104- abstract class IMergeResultBlock {
104+ abstract class MergeResultBlock {
105105 // amusingly, I can't figure out anything they have in common.
106106}
107107
108- class MergeOKResultBlock implements IMergeResultBlock {
108+ class MergeOKResultBlock implements MergeResultBlock {
109109 List <String > contentLines;
110110}
111111
112- class MergeConflictResultBlock implements IMergeResultBlock {
112+ class MergeConflictResultBlock implements MergeResultBlock {
113113 List <String > leftLines;
114114 int leftIndex;
115115 List <String > oldLines;
@@ -197,11 +197,6 @@ CandidateThing longestCommonSubsequence(List<String> file1, List<String>
197197 return candidates[candidates.length - 1 ];
198198}
199199
200- // TODO(adam): make this a closure and do not pass common;
201- //void processCommon(ref commonOrDifferentThing common, List<commonOrDifferentThing> result) {
202- // throw new UnimplementedError();
203- //}
204-
205200List <CommonOrDifferentThing > diffComm (List <String > file1, List <String > file2) {
206201 // We apply the LCS to build a "comm"-style picture of the
207202 // differences between file1 and file2.
@@ -320,11 +315,6 @@ void invertPatch(List<PatchResult> patch) {
320315 }
321316}
322317
323- // TODO(adam): make this a closure
324- //void copyCommon(int targetOffset, ref int commonOffset, string[] file, List<string> result) {
325- //
326- //}
327-
328318List <String > patch (List <String > file, List <PatchResult > patch) {
329319 // Applies a patch to a file.
330320 //
@@ -425,7 +415,7 @@ List<DiffSet> diffIndices(List<String> file1, List<String> file2) {
425415}
426416
427417// TODO(adam): make private
428- void addHunk (DiffSet h, Side side, List <Diff3Set > hunks) {
418+ void _addHunk (DiffSet h, Side side, List <Diff3Set > hunks) {
429419 Diff3Set diff3SetHunk = new Diff3Set ();
430420 diff3SetHunk
431421 ..side = side
@@ -461,11 +451,11 @@ List<Patch3Set> diff3MergeIndices(List<String> a, List<String> o, List<String>
461451 List <Diff3Set > hunks = new List <Diff3Set >();
462452
463453 for (int i = 0 ; i < m1.length; i++ ) {
464- addHunk (m1[i], Side .Left , hunks);
454+ _addHunk (m1[i], Side .LEFT , hunks);
465455 }
466456
467457 for (int i = 0 ; i < m2.length; i++ ) {
468- addHunk (m2[i], Side .Right , hunks);
458+ _addHunk (m2[i], Side .RIGHT , hunks);
469459 }
470460
471461 hunks.sort ();
@@ -477,7 +467,7 @@ List<Patch3Set> diff3MergeIndices(List<String> a, List<String> o, List<String>
477467 if (targetOffset > commonOffset) {
478468 Patch3Set patch3SetResult = new Patch3Set ();
479469 patch3SetResult
480- ..side = Side .Old
470+ ..side = Side .OLD
481471 ..offset = commonOffset
482472 ..length = targetOffset - commonOffset;
483473 result.add (patch3SetResult);
@@ -522,13 +512,13 @@ List<Patch3Set> diff3MergeIndices(List<String> a, List<String> o, List<String>
522512 // in the regions of o that each side changed, and
523513 // report appropriate spans for the three sides.
524514 Map <Side , ConflictRegion > regions = new Map <Side , ConflictRegion >();
525- regions[Side .Left ] = new ConflictRegion ()
515+ regions[Side .LEFT ] = new ConflictRegion ()
526516 ..file1RegionStart = a.length
527517 ..file1RegionEnd = - 1
528518 ..file2RegionStart = o.length
529519 ..file2RegionEnd = - 1 ;
530520
531- regions[Side .Right ] = new ConflictRegion ()
521+ regions[Side .RIGHT ] = new ConflictRegion ()
532522 ..file1RegionStart = b.length
533523 ..file1RegionEnd = - 1
534524 ..file2RegionStart = o.length
@@ -548,18 +538,18 @@ List<Patch3Set> diff3MergeIndices(List<String> a, List<String> o, List<String>
548538 r.file2RegionEnd = Math .max (oRhs, r.file2RegionEnd);
549539 }
550540
551- int aLhs = regions[Side .Left ].file1RegionStart + (regionLhs -
552- regions[Side .Left ].file2RegionStart);
553- int aRhs = regions[Side .Left ].file1RegionEnd + (regionRhs -
554- regions[Side .Left ].file2RegionEnd);
555- int bLhs = regions[Side .Right ].file1RegionStart + (regionLhs -
556- regions[Side .Right ].file2RegionStart);
557- int bRhs = regions[Side .Right ].file1RegionEnd + (regionRhs -
558- regions[Side .Right ].file2RegionEnd);
541+ int aLhs = regions[Side .LEFT ].file1RegionStart + (regionLhs -
542+ regions[Side .LEFT ].file2RegionStart);
543+ int aRhs = regions[Side .LEFT ].file1RegionEnd + (regionRhs -
544+ regions[Side .LEFT ].file2RegionEnd);
545+ int bLhs = regions[Side .RIGHT ].file1RegionStart + (regionLhs -
546+ regions[Side .RIGHT ].file2RegionStart);
547+ int bRhs = regions[Side .RIGHT ].file1RegionEnd + (regionRhs -
548+ regions[Side .RIGHT ].file2RegionEnd);
559549
560550 Patch3Set patch3SetResult = new Patch3Set ();
561551 patch3SetResult
562- ..side = Side .Conflict
552+ ..side = Side .CONFLICT
563553 ..offset = aLhs
564554 ..length = aRhs - aLhs
565555 ..conflictOldOffset = regionLhs
@@ -576,8 +566,7 @@ List<Patch3Set> diff3MergeIndices(List<String> a, List<String> o, List<String>
576566 return result;
577567}
578568
579- // TODO(adam): make private
580- void flushOk (List <String > okLines, List <IMergeResultBlock > result) {
569+ void _flushOk (List <String > okLines, List <MergeResultBlock > result) {
581570 if (okLines.length > 0 ) {
582571 MergeOKResultBlock okResult = new MergeOKResultBlock ();
583572 okResult.contentLines = okLines.toList ();
@@ -587,8 +576,7 @@ void flushOk(List<String> okLines, List<IMergeResultBlock> result) {
587576 okLines.clear ();
588577}
589578
590- // TODO(adam): make private
591- bool isTrueConflict (Patch3Set rec, List <String > a, List <String > b) {
579+ bool _isTrueConflict (Patch3Set rec, List <String > a, List <String > b) {
592580 if (rec.length != rec.conflictRightLength) {
593581 return true ;
594582 }
@@ -605,17 +593,17 @@ bool isTrueConflict(Patch3Set rec, List<String> a, List<String> b) {
605593 return false ;
606594}
607595
608- List <IMergeResultBlock > diff3Merge (List <String > a, List <String > o, List <String >
596+ List <MergeResultBlock > diff3Merge (List <String > a, List <String > o, List <String >
609597 b, bool excludeFalseConflicts) {
610598 // Applies the output of Diff.diff3_merge_indices to actually
611599 // construct the merged file; the returned result alternates
612600 // between "ok" and "conflict" blocks.
613601
614- List <IMergeResultBlock > result = new List <IMergeResultBlock >();
602+ List <MergeResultBlock > result = new List <MergeResultBlock >();
615603 Map <Side , List <String >> files = new Map <Side , List <String >>();
616- files[Side .Left ] = a;
617- files[Side .Old ] = o;
618- files[Side .Right ] = b;
604+ files[Side .LEFT ] = a;
605+ files[Side .OLD ] = o;
606+ files[Side .RIGHT ] = b;
619607
620608 List <Patch3Set > indices = diff3MergeIndices (a, o, b);
621609 List <String > okLines = new List <String >();
@@ -624,12 +612,12 @@ List<IMergeResultBlock> diff3Merge(List<String> a, List<String> o, List<String>
624612 Patch3Set x = indices[i];
625613 Side side = x.side;
626614
627- if (side == Side .Conflict ) {
628- if (excludeFalseConflicts && ! isTrueConflict (x, a, b)) {
615+ if (side == Side .CONFLICT ) {
616+ if (excludeFalseConflicts && ! _isTrueConflict (x, a, b)) {
629617 okLines.addAll (files[0 ].getRange (x.offset, x.offset + x.length).toList ()
630618 );
631619 } else {
632- flushOk (okLines, result);
620+ _flushOk (okLines, result);
633621 MergeConflictResultBlock mergeConflictResultBlock =
634622 new MergeConflictResultBlock ();
635623 mergeConflictResultBlock
@@ -649,7 +637,7 @@ List<IMergeResultBlock> diff3Merge(List<String> a, List<String> o, List<String>
649637 }
650638 }
651639
652- flushOk (okLines, result);
640+ _flushOk (okLines, result);
653641 return result;
654642}
655643
@@ -658,13 +646,13 @@ Diff3DigResult diff3Dig(String ours, String base, String theirs) {
658646 List <String > b = theirs.split ("\n " );
659647 List <String > o = base .split ("\n " );
660648
661- List <IMergeResultBlock > merger = diff3Merge (a, o, b, false );
649+ List <MergeResultBlock > merger = diff3Merge (a, o, b, false );
662650
663651 bool conflict = false ;
664652 List <String > lines = new List <String >();
665653
666654 for (int i = 0 ; i < merger.length; i++ ) {
667- IMergeResultBlock item = merger[i];
655+ MergeResultBlock item = merger[i];
668656
669657 if (item is MergeOKResultBlock ) {
670658 lines.addAll (item.contentLines);
0 commit comments