void (@NotNull PatchHunk hunk) { int baseStart = hunk.getStartLineBefore(); int baseEnd = hunk.getEndLineBefore(); int patchedStart = hunk.getStartLineAfter(); int patchedEnd = hunk.getEndLineAfter(); if (baseLine != baseStart) { error(VcsBundle.message("patch.simple.apply.hunk.base.start.error", baseLine, baseStart)); } if (patchedLine != patchedStart) { error(VcsBundle.message("patch.simple.apply.hunk.patched.start.error", patchedLine, patchedStart)); } if (baseEnd > myLineOffsets.getLineCount()) { error(VcsBundle.message("patch.simple.apply.hunk.base.end.error", myLineOffsets.getLineCount(), baseEnd)); } int baseCount = ContainerUtil.count(hunk.getLines(), patchLine -> patchLine.getType() != PatchLine.Type.ADD); int patchedCount = ContainerUtil.count(hunk.getLines(), patchLine -> patchLine.getType() != PatchLine.Type.REMOVE); if (baseCount != baseEnd - baseStart) { error(VcsBundle.message("patch.simple.apply.hunk.base.body.error", baseEnd - baseStart, baseCount)); } if (patchedCount != patchedEnd - patchedStart) { error(VcsBundle.message("patch.simple.apply.hunk.patched.body.error", patchedEnd - patchedStart, patchedCount)); } int count = 0; for (PatchLine patchLine : hunk.getLines()) { if (patchLine.getType() != PatchLine.Type.ADD) { CharSequence expectedContent = getLineContent(baseStart + count); String actualContent = patchLine.getText(); if (!StringUtil.equals(expectedContent, actualContent)) { error(VcsBundle.message("patch.simple.apply.hunk.content.error", expectedContent, patchLine)); } count++; } } }