use of com.intellij.openapi.vcs.changes.patch.AppliedTextPatch.HunkStatus.NOT_APPLIED in project intellij-community by JetBrains.
the class AppliedTextPatch method create.
public static AppliedTextPatch create(@NotNull List<AppliedSplitPatchHunk> splitPatchHunkList) {
List<AppliedSplitPatchHunk> hunks = new ArrayList<>(splitPatchHunkList);
// ensure, that `appliedTo` ranges do not overlap
BitSet appliedLines = new BitSet();
for (int i = 0; i < hunks.size(); i++) {
AppliedSplitPatchHunk hunk = hunks.get(i);
LineRange appliedTo = hunk.getAppliedTo();
if (appliedTo == null)
continue;
int nextAppliedLine = appliedLines.nextSetBit(appliedTo.start);
if (nextAppliedLine != -1 && nextAppliedLine < appliedTo.end) {
hunks.set(i, new AppliedSplitPatchHunk(hunk, -1, -1, NOT_APPLIED));
} else {
appliedLines.set(appliedTo.start, appliedTo.end, true);
}
}
ContainerUtil.sort(hunks, Comparator.comparingInt(o -> o.getLineRangeBefore().start));
return new AppliedTextPatch(hunks);
}
Aggregations