// TODO: adjust color from inner fragments - configurable public SimpleDiffChange(@NotNull SimpleDiffViewer viewer, @NotNull LineFragment fragment) { myViewer = viewer; myFragment = fragment; myInnerFragments = fragment.getInnerFragments(); installHighlighter(); }
private static String lineDiff(String actual, String expected) { List<LineFragment> fragments = myComparisonManager.compareLines(actual, expected, ComparisonPolicy.DEFAULT, INDICATOR); if (fragments.isEmpty()) { return ""; } StringBuilder diff = new StringBuilder(); diff.append("\n"); for (LineFragment fragment : fragments) { diff.append(String.format("Expected in line: %s >>>\n", fragment.getStartLine2())); diff.append(expected.substring(fragment.getStartOffset2(), fragment.getEndOffset2())); diff.append("Actual: >>>\n"); diff.append(actual.substring(fragment.getStartOffset1(), fragment.getEndOffset1())); diff.append(">>>\n\n"); } return diff.toString(); }