Mercurial > projects > dwt-addons
annotate dwtx/jface/internal/text/revisions/Hunk.d @ 138:b6bad70d540a
Regex instanceof changes
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 24 Aug 2008 02:26:23 +0200 |
parents | 51e6e63f930e |
children | 75302ef3f92f |
rev | line source |
---|---|
129 | 1 /******************************************************************************* |
2 * Copyright (c) 2006 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module dwtx.jface.internal.text.revisions.Hunk; | |
14 | |
131 | 15 import dwtx.jface.internal.text.revisions.HunkComputer; // packageimport |
16 import dwtx.jface.internal.text.revisions.LineIndexOutOfBoundsException; // packageimport | |
17 import dwtx.jface.internal.text.revisions.Colors; // packageimport | |
18 import dwtx.jface.internal.text.revisions.ChangeRegion; // packageimport | |
19 import dwtx.jface.internal.text.revisions.Range; // packageimport | |
20 import dwtx.jface.internal.text.revisions.RevisionPainter; // packageimport | |
21 import dwtx.jface.internal.text.revisions.RevisionSelectionProvider; // packageimport | |
22 | |
23 | |
129 | 24 import dwt.dwthelper.utils; |
25 | |
26 import dwtx.core.runtime.Assert; | |
27 | |
28 /** | |
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. | |
31 * | |
32 * @since 3.3 | |
33 */ | |
34 public final class Hunk { | |
35 /** | |
36 * The line at which the hunk starts in the current document. Must be in | |
37 * <code>[0, numberOfLines]</code> – note the inclusive end; there may be a hunk with | |
38 * <code>line is numberOfLines</code> to describe deleted lines at then end of the document. | |
39 */ | |
40 public final int line; | |
41 /** | |
42 * The difference in lines compared to the corresponding line range in the original. Positive | |
43 * for added lines, negative for deleted lines. | |
44 */ | |
45 public final int delta; | |
46 /** The number of changed lines in this hunk, must be >= 0. */ | |
47 public final int changed; | |
48 | |
49 /** | |
50 * Creates a new hunk. | |
51 * | |
52 * @param line the line at which the hunk starts, must be >= 0 | |
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 | |
55 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
56 public this(int line, int delta, int changed) { |
129 | 57 Assert.isLegal(line >= 0); |
58 Assert.isLegal(changed >= 0); | |
59 this.line= line; | |
60 this.delta= delta; | |
61 this.changed= changed; | |
62 } | |
63 | |
64 /* | |
65 * @see java.lang.Object#toString() | |
66 */ | |
67 public 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$ | |
69 } | |
70 | |
71 /* | |
72 * @see java.lang.Object#hashCode() | |
73 */ | |
74 public int hashCode() { | |
75 final int prime= 31; | |
76 int result= 1; | |
77 result= prime * result + changed; | |
78 result= prime * result + delta; | |
79 result= prime * result + line; | |
80 return result; | |
81 } | |
82 | |
83 /* | |
84 * @see java.lang.Object#equals(java.lang.Object) | |
85 */ | |
86 public bool equals(Object obj) { | |
87 if (obj is this) | |
88 return true; | |
138 | 89 if ( cast(Hunk)obj ) { |
134 | 90 Hunk other= cast(Hunk) obj; |
129 | 91 return other.line is this.line && other.delta is this.delta && other.changed is this.changed; |
92 } | |
93 return false; | |
94 } | |
95 } |