Skip to content

Commit e881922

Browse files
committed
refactor method names
1 parent 598dc95 commit e881922

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

bin/diff.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void main(List<String> args) {
2121
File file3 = new File(filename3);
2222
String file3Contents = file3.readAsStringSync();
2323

24-
Diff3DigResult diff3DigResult = diff3_dig(file1Contents, file2Contents,
24+
Diff3DigResult diff3DigResult = diff3Dig(file1Contents, file2Contents,
2525
file3Contents);
2626

2727
if (diff3DigResult.Conflict) {

lib/src/diff.dart

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ChunkReference {
4141
int length;
4242
}
4343

44-
class diffSet {
44+
class DiffSet {
4545
ChunkReference file1;
4646
ChunkReference file2;
4747
}
@@ -124,7 +124,7 @@ class MergeConflictResultBlock implements IMergeResultBlock {
124124
// Methods
125125
//
126126

127-
CandidateThing longest_common_subsequence(List<String> file1, List<String>
127+
CandidateThing longestCommonSubsequence(List<String> file1, List<String>
128128
file2) {
129129
/* Text diff algorithm following Hunt and McIlroy 1976.
130130
* J. W. Hunt and M. D. McIlroy, An algorithm for differential file
@@ -204,7 +204,7 @@ CandidateThing longest_common_subsequence(List<String> file1, List<String>
204204
// throw new UnimplementedError();
205205
//}
206206

207-
List<CommonOrDifferentThing> diff_comm(List<String> file1, List<String> file2) {
207+
List<CommonOrDifferentThing> diffComm(List<String> file1, List<String> file2) {
208208
// We apply the LCS to build a "comm"-style picture of the
209209
// differences between file1 and file2.
210210

@@ -225,7 +225,7 @@ List<CommonOrDifferentThing> diff_comm(List<String> file1, List<String> file2) {
225225
}
226226
}
227227

228-
for (CandidateThing candidate = longest_common_subsequence(file1, file2);
228+
for (CandidateThing candidate = longestCommonSubsequence(file1, file2);
229229
candidate != null; candidate = candidate.chain) {
230230
CommonOrDifferentThing different = new CommonOrDifferentThing()
231231
..file1 = new List<String>()
@@ -257,15 +257,15 @@ List<CommonOrDifferentThing> diff_comm(List<String> file1, List<String> file2) {
257257
return result.reversed.toList();
258258
}
259259

260-
List<PatchResult> diff_patch(List<String> file1, List<String> file2) {
260+
List<PatchResult> diffPatch(List<String> file1, List<String> file2) {
261261
// We apply the LCD to build a JSON representation of a
262262
// diff(1)-style patch.
263263

264264
List<PatchResult> result = new List<PatchResult>();
265265
int tail1 = file1.length;
266266
int tail2 = file2.length;
267267

268-
for (CandidateThing candidate = longest_common_subsequence(file1, file2);
268+
for (CandidateThing candidate = longestCommonSubsequence(file1, file2);
269269
candidate != null; candidate = candidate.chain) {
270270
int mismatchLength1 = tail1 - candidate.file1index - 1;
271271
int mismatchLength2 = tail2 - candidate.file2index - 1;
@@ -288,7 +288,7 @@ List<PatchResult> diff_patch(List<String> file1, List<String> file2) {
288288
return result.reversed.toList();
289289
}
290290

291-
List<PatchResult> strip_patch(List<PatchResult> patch) {
291+
List<PatchResult> stripPatch(List<PatchResult> patch) {
292292
// Takes the output of Diff.diff_patch(), and removes
293293
// information from it. It can still be used by patch(),
294294
// below, but can no longer be inverted.
@@ -310,7 +310,7 @@ List<PatchResult> strip_patch(List<PatchResult> patch) {
310310
return newpatch;
311311
}
312312

313-
void invert_patch(List<PatchResult> patch) {
313+
void invertPatch(List<PatchResult> patch) {
314314
// Takes the output of Diff.diff_patch(), and inverts the
315315
// sense of it, so that it can be applied to file2 to give
316316
// file1 rather than the other way around.
@@ -358,7 +358,7 @@ List<String> patch(List<String> file, List<PatchResult> patch) {
358358
return result;
359359
}
360360

361-
List<String> diff_merge_keepall(List<String> file1, List<String> file2) {
361+
List<String> diffMergeKeepall(List<String> file1, List<String> file2) {
362362
// Non-destructively merges two files.
363363
//
364364
// This is NOT a three-way merge - content will often be DUPLICATED by this process, eg
@@ -373,7 +373,7 @@ List<String> diff_merge_keepall(List<String> file1, List<String> file2) {
373373

374374
List<String> result = new List<String>();
375375
int file1CompletedToOffset = 0;
376-
List<PatchResult> diffPatches = diff_patch(file1, file2);
376+
List<PatchResult> diffPatches = diffPatch(file1, file2);
377377

378378
for (int chunkIndex = 0; chunkIndex < diffPatches.length; chunkIndex++) {
379379
PatchResult chunk = diffPatches[chunkIndex];
@@ -394,24 +394,24 @@ List<String> diff_merge_keepall(List<String> file1, List<String> file2) {
394394
return result;
395395
}
396396

397-
List<diffSet> diff_indices(List<String> file1, List<String> file2) {
397+
List<DiffSet> diffIndices(List<String> file1, List<String> file2) {
398398
// We apply the LCS to give a simple representation of the
399399
// offsets and lengths of mismatched chunks in the input
400400
// files. This is used by diff3_merge_indices below.
401401

402-
List<diffSet> result = new List<diffSet>();
402+
List<DiffSet> result = new List<DiffSet>();
403403
int tail1 = file1.length;
404404
int tail2 = file2.length;
405405

406-
for (CandidateThing candidate = longest_common_subsequence(file1, file2);
406+
for (CandidateThing candidate = longestCommonSubsequence(file1, file2);
407407
candidate != null; candidate = candidate.chain) {
408408
int mismatchLength1 = tail1 - candidate.file1index - 1;
409409
int mismatchLength2 = tail2 - candidate.file2index - 1;
410410
tail1 = candidate.file1index;
411411
tail2 = candidate.file2index;
412412

413413
if (mismatchLength1 > 0 || mismatchLength2 > 0) {
414-
diffSet diffSetResult = new diffSet();
414+
DiffSet diffSetResult = new DiffSet();
415415
diffSetResult
416416
..file1 = (new ChunkReference()
417417
..offset = tail1 + 1
@@ -427,7 +427,7 @@ List<diffSet> diff_indices(List<String> file1, List<String> file2) {
427427
}
428428

429429
// TODO(adam): make private
430-
void addHunk(diffSet h, Side side, List<Diff3Set> hunks) {
430+
void addHunk(DiffSet h, Side side, List<Diff3Set> hunks) {
431431
Diff3Set diff3SetHunk = new Diff3Set();
432432
diff3SetHunk
433433
..side = side
@@ -443,7 +443,7 @@ void addHunk(diffSet h, Side side, List<Diff3Set> hunks) {
443443
//
444444
//}
445445

446-
List<Patch3Set> diff3_merge_indices(List<String> a, List<String> o, List<String>
446+
List<Patch3Set> diff3MergeIndices(List<String> a, List<String> o, List<String>
447447
b) {
448448
// Given three files, A, O, and B, where both A and B are
449449
// independently derived from O, returns a fairly complicated
@@ -457,8 +457,8 @@ List<Patch3Set> diff3_merge_indices(List<String> a, List<String> o, List<String>
457457
//
458458
// (http://www.cis.upenn.edu/~bcpierce/papers/diff3-short.pdf)
459459

460-
List<diffSet> m1 = diff_indices(o, a);
461-
List<diffSet> m2 = diff_indices(o, b);
460+
List<DiffSet> m1 = diffIndices(o, a);
461+
List<DiffSet> m2 = diffIndices(o, b);
462462

463463
List<Diff3Set> hunks = new List<Diff3Set>();
464464

@@ -607,7 +607,7 @@ bool isTrueConflict(Patch3Set rec, List<String> a, List<String> b) {
607607
return false;
608608
}
609609

610-
List<IMergeResultBlock> diff3_merge(List<String> a, List<String> o, List<String>
610+
List<IMergeResultBlock> diff3Merge(List<String> a, List<String> o, List<String>
611611
b, bool excludeFalseConflicts) {
612612
// Applies the output of Diff.diff3_merge_indices to actually
613613
// construct the merged file; the returned result alternates
@@ -619,7 +619,7 @@ List<IMergeResultBlock> diff3_merge(List<String> a, List<String> o, List<String>
619619
files[Side.Old] = o;
620620
files[Side.Right] = b;
621621

622-
List<Patch3Set> indices = diff3_merge_indices(a, o, b);
622+
List<Patch3Set> indices = diff3MergeIndices(a, o, b);
623623
List<String> okLines = new List<String>();
624624

625625
for (int i = 0; i < indices.length; i++) {
@@ -655,12 +655,12 @@ List<IMergeResultBlock> diff3_merge(List<String> a, List<String> o, List<String>
655655
return result;
656656
}
657657

658-
Diff3DigResult diff3_dig(String ours, String base, String theirs) {
658+
Diff3DigResult diff3Dig(String ours, String base, String theirs) {
659659
List<String> a = ours.split("\n");
660660
List<String> b = theirs.split("\n");
661661
List<String> o = base.split("\n");
662662

663-
List<IMergeResultBlock> merger = diff3_merge(a, o, b, false);
663+
List<IMergeResultBlock> merger = diff3Merge(a, o, b, false);
664664

665665
bool conflict = false;
666666
List<String> lines = new List<String>();
@@ -671,7 +671,7 @@ Diff3DigResult diff3_dig(String ours, String base, String theirs) {
671671
if (item is MergeOKResultBlock) {
672672
lines.addAll(item.ContentLines);
673673
} else if (item is MergeConflictResultBlock) {
674-
List<CommonOrDifferentThing> inners = diff_comm(item.LeftLines,
674+
List<CommonOrDifferentThing> inners = diffComm(item.LeftLines,
675675
item.RightLines);
676676
for (int j = 0; j < inners.length; j++) {
677677
CommonOrDifferentThing inner = inners[j];

test/src/diff3_dig_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void defineTests() {
1616
// theirs
1717
String b = "AA a d c ZZ 11 M z z 99".split(" ").join("\n");
1818

19-
Diff3DigResult diff3DigResult = diff3_dig(a, o, b);
19+
Diff3DigResult diff3DigResult = diff3Dig(a, o, b);
2020

2121
expect(diff3DigResult, isNotNull);
2222
expect(diff3DigResult.Conflict, isTrue);

test/src/diff3_merge_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void defineTests() {
1616
// theirs
1717
List<String> b = "AA a d c ZZ 11 M z z 99".split(" ");
1818

19-
List<IMergeResultBlock> mergeResultBlocks = diff3_merge(a, o, b, false);
19+
List<IMergeResultBlock> mergeResultBlocks = diff3Merge(a, o, b, false);
2020

2121
expect(mergeResultBlocks, isNotNull);
2222
expect(mergeResultBlocks.length, equals(5));

0 commit comments

Comments
 (0)