| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.diff.display; |
| 21 |
|
|
| 22 |
|
import java.util.ArrayList; |
| 23 |
|
|
| 24 |
|
|
| 25 |
|
@link |
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
@param |
| 30 |
|
@param |
| 31 |
|
@version |
| 32 |
|
@since |
| 33 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (36) |
Complexity: 9 |
Complexity Density: 0.39 |
|
| 34 |
|
public class UnifiedDiffBlock<E, F> extends ArrayList<UnifiedDiffElement<E, F>> |
| 35 |
|
{ |
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
private static final long serialVersionUID = 1L; |
| 40 |
|
|
| 41 |
|
|
| 42 |
|
@return |
| 43 |
|
|
| 44 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 45 |
21 |
public int getPreviousStart()... |
| 46 |
|
{ |
| 47 |
21 |
for (UnifiedDiffElement<E, F> element : this) { |
| 48 |
23 |
if (!element.isAdded()) { |
| 49 |
20 |
return element.getIndex(); |
| 50 |
|
} |
| 51 |
|
} |
| 52 |
1 |
return 0; |
| 53 |
|
} |
| 54 |
|
|
| 55 |
|
|
| 56 |
|
@return |
| 57 |
|
|
| 58 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 59 |
21 |
public int getPreviousSize()... |
| 60 |
|
{ |
| 61 |
21 |
int size = 0; |
| 62 |
21 |
for (UnifiedDiffElement<E, F> element : this) { |
| 63 |
104 |
if (!element.isAdded()) { |
| 64 |
77 |
size++; |
| 65 |
|
} |
| 66 |
|
} |
| 67 |
21 |
return size; |
| 68 |
|
} |
| 69 |
|
|
| 70 |
|
|
| 71 |
|
@return |
| 72 |
|
|
| 73 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 74 |
21 |
public int getNextStart()... |
| 75 |
|
{ |
| 76 |
21 |
for (UnifiedDiffElement<E, F> element : this) { |
| 77 |
29 |
if (!element.isDeleted()) { |
| 78 |
20 |
return element.getIndex(); |
| 79 |
|
} |
| 80 |
|
} |
| 81 |
1 |
return 0; |
| 82 |
|
} |
| 83 |
|
|
| 84 |
|
|
| 85 |
|
@return |
| 86 |
|
|
| 87 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 88 |
21 |
public int getNextSize()... |
| 89 |
|
{ |
| 90 |
21 |
int size = 0; |
| 91 |
21 |
for (UnifiedDiffElement<E, F> element : this) { |
| 92 |
104 |
if (!element.isDeleted()) { |
| 93 |
79 |
size++; |
| 94 |
|
} |
| 95 |
|
} |
| 96 |
21 |
return size; |
| 97 |
|
} |
| 98 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 99 |
8 |
@Override... |
| 100 |
|
public String toString() |
| 101 |
|
{ |
| 102 |
8 |
StringBuilder stringBuilder = new StringBuilder(); |
| 103 |
|
|
| 104 |
8 |
stringBuilder.append(String.format("@@ -%s,%s +%s,%s @@\n", getPreviousStart() + 1, getPreviousSize(), |
| 105 |
|
getNextStart() + 1, getNextSize())); |
| 106 |
8 |
for (UnifiedDiffElement<E, F> element : this) { |
| 107 |
49 |
stringBuilder.append(element); |
| 108 |
|
} |
| 109 |
8 |
return stringBuilder.toString(); |
| 110 |
|
} |
| 111 |
|
} |