示例#1
0
 @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;
 }
示例#2
0
 @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);
 }
示例#3
0
 @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);
 }
示例#4
0
 @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;
 }
示例#5
0
 @Nullable
 private static DiffString toNull(@Nullable DiffString text1) {
   return text1 == null || text1.isEmpty() ? null : text1;
 }
示例#6
0
 @NotNull
 private static Object getWrapper(@NotNull DiffString line) {
   return line.skipSpaces();
 }