Mercurial > projects > dwt-addons
comparison dwtx/jface/internal/text/revisions/Hunk.d @ 162:1a5b8f8129df
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 08 Sep 2008 00:51:37 +0200 |
parents | 3678e4f1a766 |
children |
comparison
equal
deleted
inserted
replaced
161:f8d52b926852 | 162:1a5b8f8129df |
---|---|
18 import dwtx.jface.internal.text.revisions.ChangeRegion; // packageimport | 18 import dwtx.jface.internal.text.revisions.ChangeRegion; // packageimport |
19 import dwtx.jface.internal.text.revisions.Range; // packageimport | 19 import dwtx.jface.internal.text.revisions.Range; // packageimport |
20 import dwtx.jface.internal.text.revisions.RevisionPainter; // packageimport | 20 import dwtx.jface.internal.text.revisions.RevisionPainter; // packageimport |
21 import dwtx.jface.internal.text.revisions.RevisionSelectionProvider; // packageimport | 21 import dwtx.jface.internal.text.revisions.RevisionSelectionProvider; // packageimport |
22 | 22 |
23 | |
24 import dwt.dwthelper.utils; | 23 import dwt.dwthelper.utils; |
24 import tango.text.convert.Format; | |
25 | 25 |
26 import dwtx.core.runtime.Assert; | 26 import dwtx.core.runtime.Assert; |
27 | 27 |
28 /** | 28 /** |
29 * A hunk describes a contiguous range of changed, added or deleted lines. <code>Hunk</code>s are separated by | 29 * A hunk describes a contiguous range of changed, added or deleted lines. <code>Hunk</code>s are separated by |
30 * one or more unchanged lines. | 30 * one or more unchanged lines. |
31 * | 31 * |
32 * @since 3.3 | 32 * @since 3.3 |
33 */ | 33 */ |
34 public final class Hunk { | 34 public final class Hunk { |
35 /** | 35 /** |
36 * The line at which the hunk starts in the current document. Must be in | 36 * The line at which the hunk starts in the current document. Must be in |
46 /** The number of changed lines in this hunk, must be >= 0. */ | 46 /** The number of changed lines in this hunk, must be >= 0. */ |
47 public const int changed; | 47 public const int changed; |
48 | 48 |
49 /** | 49 /** |
50 * Creates a new hunk. | 50 * Creates a new hunk. |
51 * | 51 * |
52 * @param line the line at which the hunk starts, must be >= 0 | 52 * @param line the line at which the hunk starts, must be >= 0 |
53 * @param delta the difference in lines compared to the original | 53 * @param delta the difference in lines compared to the original |
54 * @param changed the number of changed lines in this hunk, must be >= 0 | 54 * @param changed the number of changed lines in this hunk, must be >= 0 |
55 */ | 55 */ |
56 public this(int line, int delta, int changed) { | 56 public this(int line, int delta, int changed) { |
63 | 63 |
64 /* | 64 /* |
65 * @see java.lang.Object#toString() | 65 * @see java.lang.Object#toString() |
66 */ | 66 */ |
67 public override String toString() { | 67 public override String toString() { |
68 return "Hunk [" + line + ">" + changed + (delta < 0 ? "-" : "+") + Math.abs(delta) + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ | 68 return Format("Hunk [{}>{}{}{}]", line, changed, delta < 0 ? "-" : "+", Math.abs(delta) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ |
69 } | 69 } |
70 | 70 |
71 /* | 71 /* |
72 * @see java.lang.Object#hashCode() | 72 * @see java.lang.Object#hashCode() |
73 */ | 73 */ |
74 public override hash_t toHash() { | 74 public override hash_t toHash() { |
75 final int prime= 31; | 75 final int prime= 31; |
81 } | 81 } |
82 | 82 |
83 /* | 83 /* |
84 * @see java.lang.Object#equals(java.lang.Object) | 84 * @see java.lang.Object#equals(java.lang.Object) |
85 */ | 85 */ |
86 public bool equals(Object obj) { | 86 public override int opEquals(Object obj) { |
87 if (obj is this) | 87 if (obj is this) |
88 return true; | 88 return true; |
89 if ( cast(Hunk)obj ) { | 89 if ( Hunk other= cast(Hunk)obj ) { |
90 Hunk other= cast(Hunk) obj; | |
91 return other.line is this.line && other.delta is this.delta && other.changed is this.changed; | 90 return other.line is this.line && other.delta is this.delta && other.changed is this.changed; |
92 } | 91 } |
93 return false; | 92 return false; |
94 } | 93 } |
95 } | 94 } |