MCPcopy Create free account
hub / github.com/diffplug/goomph / computeDiff

Method computeDiff

src/test/java/com/diffplug/gradle/Diff.java:25–46  ·  view source on GitHub ↗
(String before, String after)

Source from the content-addressed store, hash-verified

23/** Creates diffs which are easy to assert against. */
24public class Diff {
25 public static String computeDiff(String before, String after) {
26 diff_match_patch differ = new diff_match_patch();
27 LinkedList<diff_match_patch.Diff> diffs = differ.diff_main(before, after);
28 differ.diff_cleanupEfficiency(diffs);
29 differ.diff_cleanupSemantic(diffs);
30 return StringPrinter.buildString(printer -> {
31 for (diff_match_patch.Diff diff : diffs) {
32 switch (diff.operation) {
33 case EQUAL:
34 // do nothing
35 break;
36 case DELETE:
37 case INSERT:
38 printer.println(diff.operation.name());
39 printer.println(FileMisc.toUnixNewline(diff.text));
40 break;
41 default:
42 throw Unhandled.enumException(diff.operation);
43 }
44 }
45 });
46 }
47}

Calls 5

diff_mainMethod · 0.95
diff_cleanupSemanticMethod · 0.95
toUnixNewlineMethod · 0.95
nameMethod · 0.45

Tested by

no test coverage detected