diff dwtx/jface/internal/text/revisions/Range.d @ 162:1a5b8f8129df

...
author Frank Benoit <benoit@tionex.de>
date Mon, 08 Sep 2008 00:51:37 +0200
parents 6dcb0baaa031
children
line wrap: on
line diff
--- a/dwtx/jface/internal/text/revisions/Range.d	Wed Aug 27 14:49:30 2008 +0200
+++ b/dwtx/jface/internal/text/revisions/Range.d	Mon Sep 08 00:51:37 2008 +0200
@@ -20,8 +20,8 @@
 import dwtx.jface.internal.text.revisions.RevisionPainter; // packageimport
 import dwtx.jface.internal.text.revisions.RevisionSelectionProvider; // packageimport
 
-
 import dwt.dwthelper.utils;
+import tango.text.convert.Format;
 
 import dwtx.jface.text.source.ILineRange;
 
@@ -36,13 +36,13 @@
  * result in a {@link LineIndexOutOfBoundsException} being
  * thrown.
  * </p>
- * 
+ *
  * @since 3.2
  */
 public final class Range : ILineRange, Cloneable {
     /**
      * Creates a new range with the same start and length as the passed line range.
-     * 
+     *
      * @param range the range to copy
      * @return a <code>Range</code> with the same start and length as <code>range</code>
      * @throws LineIndexOutOfBoundsException if the passed {@link ILineRange} does not adhere to the
@@ -51,20 +51,20 @@
     public static Range copy(ILineRange range)  {
         return createRelative(range.getStartLine(), range.getNumberOfLines());
     }
-    
+
     /**
      * Creates a new range equal to the passed line range.
-     * 
+     *
      * @param range the range to copy
      * @return a <code>Range</code> equal to <code>range</code>
      */
     public static Range copy(Range range) {
         return createRelative(range.start(), range.length());
     }
-    
+
     /**
      * Creates a new range with the given start offset and length.
-     * 
+     *
      * @param start the first line of the new range, must be &gt;= 0
      * @param length the number of lines included in the new range, must be &gt; 0
      * @return a <code>Range</code> with the given start and length
@@ -77,7 +77,7 @@
 
     /**
      * Creates a new range with the given start and end offsets.
-     * 
+     *
      * @param start the first line of the new range, must be &gt;= 0
      * @param end the first line not in the range any more (exclusive), must be &gt; <code>start</code>
      * @return a <code>Range</code> with the given start and end offsets
@@ -98,7 +98,7 @@
         moveTo(start);
         setLength(length);
     }
-    
+
     /*
      * @see dwtx.jface.text.source.ILineRange#getStartLine()
      */
@@ -112,154 +112,154 @@
     public int getNumberOfLines() {
         return length();
     }
-    
+
     /**
      * Returns the first line contained in this range. Short equivalent of {@link #getStartLine()}.
-     * 
+     *
      * @return the first line contained in this range
      */
     public int start() {
         return fStart;
     }
-    
+
     /**
      * Returns the number of lines contained in this range. Short equivalent of {@link #getNumberOfLines()}.
-     * 
+     *
      * @return the number of lines contained in this range
      */
     public int length() {
         return fLength;
     }
-    
+
     /**
      * Returns the first line after this range. Equivalent to {@linkplain #start() start} + {@linkplain #length() length}.
-     * 
+     *
      * @return the first line after this range
      */
     public int end() {
         return start() + length();
     }
-    
+
     /**
      * Moves the receiver to <code>start</code>, keeping {@link #length()} constant.
-     * 
+     *
      * @param start the new start, must be &gt;= 0
      * @throws LineIndexOutOfBoundsException if <code>start</code> &lt; 0
      */
     public void moveTo(int start)  {
         if (!(start >= 0))
-            throw new LineIndexOutOfBoundsException("Cannot set a negative start: " + start); //$NON-NLS-1$
+            throw new LineIndexOutOfBoundsException(Format("Cannot set a negative start: {}", start)); //$NON-NLS-1$
         fStart= start;
     }
-    
+
     /**
      * Moves this range such that the {@link #end()} is at <code>end</code>, keeping
      * {@link #length()} constant.
-     * 
+     *
      * @param end the new end
      * @throws LineIndexOutOfBoundsException if <code>end</code> &lt;= {@link #start()}
      */
     public void moveEndTo(int end)  {
         moveTo(end - length());
     }
-    
+
     /**
      * Moves the range by <code>delta</code> lines, keeping {@link #length()} constant. The
      * resulting start line must be &gt;= 0.
-     * 
+     *
      * @param delta the number of lines to shift the range
      * @throws LineIndexOutOfBoundsException if <code>-delta</code> &gt; {@link #start()}
      */
     public void moveBy(int delta)  {
         moveTo(start() + delta);
     }
-    
+
     /**
      * Moves the start offset to <code>start</code>, keeping {@link #end()} constant.
-     * 
+     *
      * @param start the new start, must be &gt;= 0 and &lt; {@link #end()}
      * @throws LineIndexOutOfBoundsException if <code>start</code> &lt; 0 or &gt;= {@link #end()}
      */
     public void setStart(int start)  {
         int end= end();
         if (!(start >= 0 && start < end))
-            throw new LineIndexOutOfBoundsException("Cannot set a negative start: " + start); //$NON-NLS-1$
+            throw new LineIndexOutOfBoundsException(Format("Cannot set a negative start: {}", start)); //$NON-NLS-1$
         moveTo(start);
         setEnd(end);
     }
-    
+
     /**
      * Sets the end of this range, keeping {@link #start()} constant.
-     * 
+     *
      * @param end the new end, must be &gt; {@link #start()}
      * @throws LineIndexOutOfBoundsException if <code>end</code> &lt;= {@link #start()}
      */
     public void setEnd(int end)  {
         setLength(end - start());
     }
-    
+
     /**
      * Sets the length of this range, keeping {@link #start()} constant.
-     * 
+     *
      * @param length the new length, must be &gt; 0
      * @throws LineIndexOutOfBoundsException if <code>length</code> &lt;= 0
      */
     public void setLength(int length)  {
         if (!(length > 0))
-            throw new LineIndexOutOfBoundsException("Cannot set length <= 0: " + length); //$NON-NLS-1$
+            throw new LineIndexOutOfBoundsException(Format("Cannot set length <= 0: {}", length)); //$NON-NLS-1$
         fLength= length;
     }
-    
+
     /**
      * Sets the length of this range, keeping {@link #end()} constant.
-     * 
+     *
      * @param length the new length, must be &gt; 0 and &lt;= {@link #end()}
      * @throws LineIndexOutOfBoundsException if <code>length</code> &lt;= 0
      */
     public void setLengthAndMove(int length)  {
         setStart(end() - length);
     }
-    
+
     /**
      * Resizes the range by <code>delta</code> lines, keeping {@link #start()} constant.
-     * 
+     *
      * @param delta the number of lines to resize the range
-     * @throws LineIndexOutOfBoundsException if <code>-delta</code> &gt;= {@link #length()} 
+     * @throws LineIndexOutOfBoundsException if <code>-delta</code> &gt;= {@link #length()}
      */
     public void resizeBy(int delta)  {
         setLength(length() + delta);
     }
-    
+
     /**
      * Resizes the range by <code>delta</code> lines by moving the start offset, {@link #end()} remains unchanged.
-     * 
+     *
      * @param delta the number of lines to resize the range
-     * @throws LineIndexOutOfBoundsException if <code>-delta</code> &gt;= {@link #length()} 
+     * @throws LineIndexOutOfBoundsException if <code>-delta</code> &gt;= {@link #length()}
      */
     public void resizeAndMoveBy(int delta)  {
         setStart(start() + delta);
     }
-    
+
     /**
      * Splits a range off the end of the receiver. The receiver is shortened to only include
      * <code>remaining</code> lines after the split.
-     * 
+     *
      * @param remaining the number of lines to remain in the receiver, must be in [1, {@link #length() length})
      * @return the split off range
      * @throws LineIndexOutOfBoundsException if <code>remaining</code>&gt;= {@link #length()} or <code>remaining</code>&ltt;= 0
      */
     public Range split(int remaining)  {
         if (!(remaining < length())) // assert before modification
-            throw new LineIndexOutOfBoundsException("Remaining must be less than length: " + length()); //$NON-NLS-1$
+            throw new LineIndexOutOfBoundsException(Format("Remaining must be less than length: {}", length())); //$NON-NLS-1$
 
         int splitLength= length() - remaining;
         setLength(remaining);
         return new Range(end(), splitLength);
     }
-    
+
     /**
      * Returns <code>true</code> if the passed range has the same offset and length as the receiver.
-     * 
+     *
      * @param range another line range to compare the receiver to
      * @return <code>true</code> if <code>range</code> has the same offset and length as the receiver
      */
@@ -270,7 +270,7 @@
             return false;
         return range.getStartLine() is start() && range.getNumberOfLines() is length();
     }
-    
+
     /*
      * @see java.lang.Object#clone()
      */