comparison dwtx/jface/internal/text/revisions/Range.d @ 136:6dcb0baaa031

Regex removal of throws decls, some instanceof
author Frank Benoit <benoit@tionex.de>
date Sun, 24 Aug 2008 02:20:40 +0200
parents 7d818bd32d63
children 1a5b8f8129df
comparison
equal deleted inserted replaced
135:65801ad2b265 136:6dcb0baaa031
46 * @param range the range to copy 46 * @param range the range to copy
47 * @return a <code>Range</code> with the same start and length as <code>range</code> 47 * @return a <code>Range</code> with the same start and length as <code>range</code>
48 * @throws LineIndexOutOfBoundsException if the passed {@link ILineRange} does not adhere to the 48 * @throws LineIndexOutOfBoundsException if the passed {@link ILineRange} does not adhere to the
49 * contract of {@link Range} 49 * contract of {@link Range}
50 */ 50 */
51 public static Range copy(ILineRange range) throws LineIndexOutOfBoundsException { 51 public static Range copy(ILineRange range) {
52 return createRelative(range.getStartLine(), range.getNumberOfLines()); 52 return createRelative(range.getStartLine(), range.getNumberOfLines());
53 } 53 }
54 54
55 /** 55 /**
56 * Creates a new range equal to the passed line range. 56 * Creates a new range equal to the passed line range.
69 * @param length the number of lines included in the new range, must be &gt; 0 69 * @param length the number of lines included in the new range, must be &gt; 0
70 * @return a <code>Range</code> with the given start and length 70 * @return a <code>Range</code> with the given start and length
71 * @throws LineIndexOutOfBoundsException if the parameters violate the invariant of 71 * @throws LineIndexOutOfBoundsException if the parameters violate the invariant of
72 * {@link Range} 72 * {@link Range}
73 */ 73 */
74 public static Range createRelative(int start, int length) throws LineIndexOutOfBoundsException { 74 public static Range createRelative(int start, int length) {
75 return new Range(start, length); 75 return new Range(start, length);
76 } 76 }
77 77
78 /** 78 /**
79 * Creates a new range with the given start and end offsets. 79 * Creates a new range with the given start and end offsets.
144 * Moves the receiver to <code>start</code>, keeping {@link #length()} constant. 144 * Moves the receiver to <code>start</code>, keeping {@link #length()} constant.
145 * 145 *
146 * @param start the new start, must be &gt;= 0 146 * @param start the new start, must be &gt;= 0
147 * @throws LineIndexOutOfBoundsException if <code>start</code> &lt; 0 147 * @throws LineIndexOutOfBoundsException if <code>start</code> &lt; 0
148 */ 148 */
149 public void moveTo(int start) throws LineIndexOutOfBoundsException { 149 public void moveTo(int start) {
150 if (!(start >= 0)) 150 if (!(start >= 0))
151 throw new LineIndexOutOfBoundsException("Cannot set a negative start: " + start); //$NON-NLS-1$ 151 throw new LineIndexOutOfBoundsException("Cannot set a negative start: " + start); //$NON-NLS-1$
152 fStart= start; 152 fStart= start;
153 } 153 }
154 154
157 * {@link #length()} constant. 157 * {@link #length()} constant.
158 * 158 *
159 * @param end the new end 159 * @param end the new end
160 * @throws LineIndexOutOfBoundsException if <code>end</code> &lt;= {@link #start()} 160 * @throws LineIndexOutOfBoundsException if <code>end</code> &lt;= {@link #start()}
161 */ 161 */
162 public void moveEndTo(int end) throws LineIndexOutOfBoundsException { 162 public void moveEndTo(int end) {
163 moveTo(end - length()); 163 moveTo(end - length());
164 } 164 }
165 165
166 /** 166 /**
167 * Moves the range by <code>delta</code> lines, keeping {@link #length()} constant. The 167 * Moves the range by <code>delta</code> lines, keeping {@link #length()} constant. The
168 * resulting start line must be &gt;= 0. 168 * resulting start line must be &gt;= 0.
169 * 169 *
170 * @param delta the number of lines to shift the range 170 * @param delta the number of lines to shift the range
171 * @throws LineIndexOutOfBoundsException if <code>-delta</code> &gt; {@link #start()} 171 * @throws LineIndexOutOfBoundsException if <code>-delta</code> &gt; {@link #start()}
172 */ 172 */
173 public void moveBy(int delta) throws LineIndexOutOfBoundsException { 173 public void moveBy(int delta) {
174 moveTo(start() + delta); 174 moveTo(start() + delta);
175 } 175 }
176 176
177 /** 177 /**
178 * Moves the start offset to <code>start</code>, keeping {@link #end()} constant. 178 * Moves the start offset to <code>start</code>, keeping {@link #end()} constant.
179 * 179 *
180 * @param start the new start, must be &gt;= 0 and &lt; {@link #end()} 180 * @param start the new start, must be &gt;= 0 and &lt; {@link #end()}
181 * @throws LineIndexOutOfBoundsException if <code>start</code> &lt; 0 or &gt;= {@link #end()} 181 * @throws LineIndexOutOfBoundsException if <code>start</code> &lt; 0 or &gt;= {@link #end()}
182 */ 182 */
183 public void setStart(int start) throws LineIndexOutOfBoundsException { 183 public void setStart(int start) {
184 int end= end(); 184 int end= end();
185 if (!(start >= 0 && start < end)) 185 if (!(start >= 0 && start < end))
186 throw new LineIndexOutOfBoundsException("Cannot set a negative start: " + start); //$NON-NLS-1$ 186 throw new LineIndexOutOfBoundsException("Cannot set a negative start: " + start); //$NON-NLS-1$
187 moveTo(start); 187 moveTo(start);
188 setEnd(end); 188 setEnd(end);
192 * Sets the end of this range, keeping {@link #start()} constant. 192 * Sets the end of this range, keeping {@link #start()} constant.
193 * 193 *
194 * @param end the new end, must be &gt; {@link #start()} 194 * @param end the new end, must be &gt; {@link #start()}
195 * @throws LineIndexOutOfBoundsException if <code>end</code> &lt;= {@link #start()} 195 * @throws LineIndexOutOfBoundsException if <code>end</code> &lt;= {@link #start()}
196 */ 196 */
197 public void setEnd(int end) throws LineIndexOutOfBoundsException { 197 public void setEnd(int end) {
198 setLength(end - start()); 198 setLength(end - start());
199 } 199 }
200 200
201 /** 201 /**
202 * Sets the length of this range, keeping {@link #start()} constant. 202 * Sets the length of this range, keeping {@link #start()} constant.
203 * 203 *
204 * @param length the new length, must be &gt; 0 204 * @param length the new length, must be &gt; 0
205 * @throws LineIndexOutOfBoundsException if <code>length</code> &lt;= 0 205 * @throws LineIndexOutOfBoundsException if <code>length</code> &lt;= 0
206 */ 206 */
207 public void setLength(int length) throws LineIndexOutOfBoundsException { 207 public void setLength(int length) {
208 if (!(length > 0)) 208 if (!(length > 0))
209 throw new LineIndexOutOfBoundsException("Cannot set length <= 0: " + length); //$NON-NLS-1$ 209 throw new LineIndexOutOfBoundsException("Cannot set length <= 0: " + length); //$NON-NLS-1$
210 fLength= length; 210 fLength= length;
211 } 211 }
212 212
214 * Sets the length of this range, keeping {@link #end()} constant. 214 * Sets the length of this range, keeping {@link #end()} constant.
215 * 215 *
216 * @param length the new length, must be &gt; 0 and &lt;= {@link #end()} 216 * @param length the new length, must be &gt; 0 and &lt;= {@link #end()}
217 * @throws LineIndexOutOfBoundsException if <code>length</code> &lt;= 0 217 * @throws LineIndexOutOfBoundsException if <code>length</code> &lt;= 0
218 */ 218 */
219 public void setLengthAndMove(int length) throws LineIndexOutOfBoundsException { 219 public void setLengthAndMove(int length) {
220 setStart(end() - length); 220 setStart(end() - length);
221 } 221 }
222 222
223 /** 223 /**
224 * Resizes the range by <code>delta</code> lines, keeping {@link #start()} constant. 224 * Resizes the range by <code>delta</code> lines, keeping {@link #start()} constant.
225 * 225 *
226 * @param delta the number of lines to resize the range 226 * @param delta the number of lines to resize the range
227 * @throws LineIndexOutOfBoundsException if <code>-delta</code> &gt;= {@link #length()} 227 * @throws LineIndexOutOfBoundsException if <code>-delta</code> &gt;= {@link #length()}
228 */ 228 */
229 public void resizeBy(int delta) throws LineIndexOutOfBoundsException { 229 public void resizeBy(int delta) {
230 setLength(length() + delta); 230 setLength(length() + delta);
231 } 231 }
232 232
233 /** 233 /**
234 * Resizes the range by <code>delta</code> lines by moving the start offset, {@link #end()} remains unchanged. 234 * Resizes the range by <code>delta</code> lines by moving the start offset, {@link #end()} remains unchanged.
235 * 235 *
236 * @param delta the number of lines to resize the range 236 * @param delta the number of lines to resize the range
237 * @throws LineIndexOutOfBoundsException if <code>-delta</code> &gt;= {@link #length()} 237 * @throws LineIndexOutOfBoundsException if <code>-delta</code> &gt;= {@link #length()}
238 */ 238 */
239 public void resizeAndMoveBy(int delta) throws LineIndexOutOfBoundsException { 239 public void resizeAndMoveBy(int delta) {
240 setStart(start() + delta); 240 setStart(start() + delta);
241 } 241 }
242 242
243 /** 243 /**
244 * Splits a range off the end of the receiver. The receiver is shortened to only include 244 * Splits a range off the end of the receiver. The receiver is shortened to only include
246 * 246 *
247 * @param remaining the number of lines to remain in the receiver, must be in [1, {@link #length() length}) 247 * @param remaining the number of lines to remain in the receiver, must be in [1, {@link #length() length})
248 * @return the split off range 248 * @return the split off range
249 * @throws LineIndexOutOfBoundsException if <code>remaining</code>&gt;= {@link #length()} or <code>remaining</code>&ltt;= 0 249 * @throws LineIndexOutOfBoundsException if <code>remaining</code>&gt;= {@link #length()} or <code>remaining</code>&ltt;= 0
250 */ 250 */
251 public Range split(int remaining) throws LineIndexOutOfBoundsException { 251 public Range split(int remaining) {
252 if (!(remaining < length())) // assert before modification 252 if (!(remaining < length())) // assert before modification
253 throw new LineIndexOutOfBoundsException("Remaining must be less than length: " + length()); //$NON-NLS-1$ 253 throw new LineIndexOutOfBoundsException("Remaining must be less than length: " + length()); //$NON-NLS-1$
254 254
255 int splitLength= length() - remaining; 255 int splitLength= length() - remaining;
256 setLength(remaining); 256 setLength(remaining);