Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1151905

Browse filesBrowse files
committed
1 parent 0312493 commit 1151905
Copy full SHA for 1151905

File tree

Expand file treeCollapse file tree

5 files changed

+6
-54
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+6
-54
lines changed

‎src/main/java/difflib/patch/ChangeDelta.java

Copy file name to clipboardExpand all lines: src/main/java/difflib/patch/ChangeDelta.java
-20Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ public ChangeDelta(Chunk<T> original, Chunk<T> revised) {
3939
super(DeltaType.CHANGE, original, revised);
4040
}
4141

42-
/**
43-
* {@inheritDoc}
44-
*
45-
* @throws PatchFailedException
46-
*/
4742
@Override
4843
public void applyTo(List<T> target) throws PatchFailedException {
4944
verify(target);
@@ -59,9 +54,6 @@ public void applyTo(List<T> target) throws PatchFailedException {
5954
}
6055
}
6156

62-
/**
63-
* {@inheritDoc}
64-
*/
6557
@Override
6658
public void restore(List<T> target) {
6759
int position = getRevised().getPosition();
@@ -76,18 +68,6 @@ public void restore(List<T> target) {
7668
}
7769
}
7870

79-
/**
80-
* {@inheritDoc}
81-
*/
82-
@Override
83-
public void verify(List<T> target) throws PatchFailedException {
84-
getOriginal().verify(target);
85-
if (getOriginal().getPosition() > target.size()) {
86-
throw new PatchFailedException("Incorrect patch for delta: "
87-
+ "delta original position > target size");
88-
}
89-
}
90-
9171
@Override
9272
public String toString() {
9373
return "[ChangeDelta, position: " + getOriginal().getPosition() + ", lines: "

‎src/main/java/difflib/patch/Chunk.java

Copy file name to clipboardExpand all lines: src/main/java/difflib/patch/Chunk.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public Chunk(int position, T[] lines) {
6868
* @param target the sequence to verify against.
6969
*/
7070
public void verify(List<T> target) throws PatchFailedException {
71-
if (last() > target.size()) {
71+
if (position > target.size() || last() > target.size()) {
7272
throw new PatchFailedException("Incorrect Chunk: the position of chunk > target size");
7373
}
7474
for (int i = 0; i < size(); i++) {

‎src/main/java/difflib/patch/DeleteDelta.java

Copy file name to clipboardExpand all lines: src/main/java/difflib/patch/DeleteDelta.java
+1-14Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ public DeleteDelta(Chunk<T> original, Chunk<T> revised) {
3939
super(DeltaType.DELETE, original, revised);
4040
}
4141

42-
/**
43-
* {@inheritDoc}
44-
*
45-
* @throws PatchFailedException
46-
*/
4742
@Override
4843
public void applyTo(List<T> target) throws PatchFailedException {
4944
verify(target);
@@ -53,10 +48,7 @@ public void applyTo(List<T> target) throws PatchFailedException {
5348
target.remove(position);
5449
}
5550
}
56-
57-
/**
58-
* {@inheritDoc}
59-
*/
51+
6052
@Override
6153
public void restore(List<T> target) {
6254
int position = this.getRevised().getPosition();
@@ -66,11 +58,6 @@ public void restore(List<T> target) {
6658
}
6759
}
6860

69-
@Override
70-
public void verify(List<T> target) throws PatchFailedException {
71-
getOriginal().verify(target);
72-
}
73-
7461
@Override
7562
public String toString() {
7663
return "[DeleteDelta, position: " + getOriginal().getPosition() + ", lines: "

‎src/main/java/difflib/patch/Delta.java

Copy file name to clipboardExpand all lines: src/main/java/difflib/patch/Delta.java
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ public Delta(DeltaType deltaType, Chunk<T> original, Chunk<T> revised) {
7979
* @param target the text to patch.
8080
* @throws PatchFailedException if the patch cannot be applied.
8181
*/
82-
public abstract void verify(List<T> target) throws PatchFailedException;
82+
public void verify(List<T> target) throws PatchFailedException {
83+
getOriginal().verify(target);
84+
}
8385

8486
/**
8587
* Applies this delta as the patch for a given target

‎src/main/java/difflib/patch/InsertDelta.java

Copy file name to clipboardExpand all lines: src/main/java/difflib/patch/InsertDelta.java
+1-18Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ public InsertDelta(Chunk<T> original, Chunk<T> revised) {
3939
super(DeltaType.INSERT, original, revised);
4040
}
4141

42-
/**
43-
* {@inheritDoc}
44-
*
45-
* @throws PatchFailedException
46-
*/
4742
@Override
4843
public void applyTo(List<T> target) throws PatchFailedException {
4944
verify(target);
@@ -53,10 +48,7 @@ public void applyTo(List<T> target) throws PatchFailedException {
5348
target.add(position + i, lines.get(i));
5449
}
5550
}
56-
57-
/**
58-
* {@inheritDoc}
59-
*/
51+
6052
@Override
6153
public void restore(List<T> target) {
6254
int position = getRevised().getPosition();
@@ -66,15 +58,6 @@ public void restore(List<T> target) {
6658
}
6759
}
6860

69-
@Override
70-
public void verify(List<T> target) throws PatchFailedException {
71-
if (getOriginal().getPosition() > target.size()) {
72-
throw new PatchFailedException("Incorrect patch for delta: "
73-
+ "delta original position > target size");
74-
}
75-
76-
}
77-
7861
@Override
7962
public String toString() {
8063
return "[InsertDelta, position: " + getOriginal().getPosition()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.