@NotNull protected Object[] trimStrings(@NotNull DiffString[] strings) { Object[] result = new Object[strings.length]; for (int i = 0; i < strings.length; i++) { DiffString string = strings[i]; result[i] = string.trim(); } return result; }
@NotNull @TestOnly protected Object[] getLineWrappers(@NotNull String[] lines) { DiffString[] unsafeStrings = new DiffString[lines.length]; for (int i = 0; i < lines.length; i++) { unsafeStrings[i] = DiffString.createNullable(lines[i]); } return getLineWrappers(unsafeStrings); }
@Override public void process( @NotNull DiffFragment fragment, @NotNull DiffCorrection.FragmentsCollector collector) { if (fragment.isEqual()) { collector.add(fragment); return; } if (fragment.isOneSide()) { FragmentSide side = FragmentSide.chooseSide(fragment); DiffString text = side.getText(fragment); DiffString trimed = text.trim(); if (trimed.isEmpty()) { collector.add(side.createFragment(text, DiffString.EMPTY, false)); return; } } collector.add(fragment); }
@NotNull @Override protected Object[] getWrappers(@NotNull DiffString[] strings) { Object[] result = new Object[strings.length]; boolean atBeginning = true; for (int i = 0; i < strings.length; i++) { DiffString string = strings[i]; DiffString wrapper = atBeginning ? string.trimLeading() : string; if (wrapper.endsWith('\n')) { atBeginning = true; wrapper = wrapper.trimTrailing(); } else { atBeginning = false; } result[i] = wrapper; } return result; }
@Nullable private static DiffString toNull(@Nullable DiffString text1) { return text1 == null || text1.isEmpty() ? null : text1; }
@NotNull private static Object getWrapper(@NotNull DiffString line) { return line.skipSpaces(); }