diff dwtx/jface/text/TreeLineTracker.d @ 134:51e6e63f930e

Regex fix for casts
author Frank Benoit <benoit@tionex.de>
date Sun, 24 Aug 2008 01:46:20 +0200
parents 7d818bd32d63
children 6dcb0baaa031
line wrap: on
line diff
--- a/dwtx/jface/text/TreeLineTracker.d	Sun Aug 24 01:29:22 2008 +0200
+++ b/dwtx/jface/text/TreeLineTracker.d	Sun Aug 24 01:46:20 2008 +0200
@@ -322,7 +322,7 @@
         if (n is 0)
             return;
         
-        Line line= (Line) lines.get(0);
+        Line line= cast(Line) lines.get(0);
         String delim= line.delimiter;
         if (delim is null)
             delim= NO_DELIM;
@@ -331,7 +331,7 @@
         Node node= fRoot;
         
         for (int i= 1; i < n; i++) {
-            line= (Line) lines.get(i);
+            line= cast(Line) lines.get(i);
             delim= line.delimiter;
             if (delim is null)
                 delim= NO_DELIM;
@@ -342,7 +342,7 @@
         if (node.delimiter !is NO_DELIM)
             insertAfter(node, 0, NO_DELIM);
         
-        if (ASSERT) checkTree();
+        if cast(ASSERT) checkTree();
     }
 
     /**
@@ -504,9 +504,9 @@
      * @param node the node to rotate around
      */
     private void rotateLeft(Node node) {
-        if (ASSERT) Assert.isNotNull(node);
+        if cast(ASSERT) Assert.isNotNull(node);
         Node child= node.right;
-        if (ASSERT) Assert.isNotNull(child);
+        if cast(ASSERT) Assert.isNotNull(child);
         bool leftChild= node.parent is null || node is node.parent.left;
         
         // restructure
@@ -529,9 +529,9 @@
      * @param node the node to rotate around
      */
     private void rotateRight(Node node) {
-        if (ASSERT) Assert.isNotNull(node);
+        if cast(ASSERT) Assert.isNotNull(node);
         Node child= node.left;
-        if (ASSERT) Assert.isNotNull(child);
+        if cast(ASSERT) Assert.isNotNull(child);
         bool leftChild= node.parent is null || node is node.parent.left;
         
         setChild(node.parent, child, leftChild);
@@ -705,7 +705,7 @@
                 case 0:
                     break;
                 default:
-                    if (ASSERT) 
+                    if cast(ASSERT) 
                         Assert.isTrue(false);
             }
             return;
@@ -723,7 +723,7 @@
             singleLeftRotation(node, parent);
         } else if (node.balance is -1) {
             rightLeftRotation(node, parent);
-        } else if (ASSERT) {
+        } else if cast(ASSERT) {
             Assert.isTrue(false);
         }
     }
@@ -739,7 +739,7 @@
             singleRightRotation(node, parent);
         } else if (node.balance is 1) {
             leftRightRotation(node, parent);
-        } else if (ASSERT) {
+        } else if cast(ASSERT) {
             Assert.isTrue(false);
         }
     }
@@ -748,7 +748,7 @@
      * @see dwtx.jface.text.ILineTracker#replace(int, int, java.lang.String)
      */
     public final void replace(int offset, int length, String text) throws BadLocationException {
-        if (ASSERT) checkTree();
+        if cast(ASSERT) checkTree();
         
         // Inlined nodeByOffset as we need both node and offset
         int remaining= offset;
@@ -773,14 +773,14 @@
             }
         }
         // Inline nodeByOffset end
-        if (ASSERT) Assert.isTrue(first !is null);
+        if cast(ASSERT) Assert.isTrue(first !is null);
         
         Node last;
         if (offset + length < firstNodeOffset + first.length)
             last= first;
         else
             last= nodeByOffset(offset + length);
-        if (ASSERT) Assert.isTrue(last !is null);
+        if cast(ASSERT) Assert.isTrue(last !is null);
         
         int firstLineDelta= firstNodeOffset + first.length - offset;
         if (first is last)
@@ -788,7 +788,7 @@
         else
             replaceFromTo(first, last, text, length, firstLineDelta);
 
-        if (ASSERT) checkTree();
+        if cast(ASSERT) checkTree();
     }
 
     /**
@@ -913,7 +913,7 @@
      * @param delta the character delta to add to the node's length
      */
     private void updateLength(Node node, int delta) {
-        if (ASSERT) Assert.isTrue(node.length  + delta >= 0);
+        if cast(ASSERT) Assert.isTrue(node.length  + delta >= 0);
         
         // update the node itself
         node.length += delta;
@@ -978,8 +978,8 @@
      * @param node the node to delete.
      */
     private void delete(Node node) {
-        if (ASSERT) Assert.isTrue(node !is null);
-        if (ASSERT) Assert.isTrue(node.length is 0);
+        if cast(ASSERT) Assert.isTrue(node !is null);
+        if cast(ASSERT) Assert.isTrue(node.length is 0);
         
         Node parent= node.parent;
         Node toUpdate; // the parent of the node that lost a child
@@ -1018,15 +1018,15 @@
             Node successor= successor(node);
             
             // successor exists (otherwise node would not have right child, case 1)
-            if (ASSERT) Assert.isNotNull(successor);
+            if cast(ASSERT) Assert.isNotNull(successor);
             // successor has no left child (a left child would be the real successor of node)
-            if (ASSERT) Assert.isTrue(successor.left is null);
-            if (ASSERT) Assert.isTrue(successor.line is 0);
+            if cast(ASSERT) Assert.isTrue(successor.left is null);
+            if cast(ASSERT) Assert.isTrue(successor.line is 0);
             // successor is the left child of its parent (otherwise parent would be smaller and
             // hence the real successor)
-            if (ASSERT) Assert.isTrue(successor is successor.parent.left);
+            if cast(ASSERT) Assert.isTrue(successor is successor.parent.left);
             // successor is not a child of node (would have been covered by 2a)
-            if (ASSERT) Assert.isTrue(successor.parent !is node);
+            if cast(ASSERT) Assert.isTrue(successor.parent !is node);
 
             toUpdate= successor.parent;
             lostLeftChild= true;
@@ -1087,7 +1087,7 @@
                 case 0:
                     break; // propagate up
                 default:
-                    if (ASSERT) 
+                    if cast(ASSERT) 
                         Assert.isTrue(false);
             }
             
@@ -1116,7 +1116,7 @@
             parent.balance= 1;
             return true;
         } else {
-            if (ASSERT) Assert.isTrue(false);
+            if cast(ASSERT) Assert.isTrue(false);
             return true;
         }
     }
@@ -1142,7 +1142,7 @@
             parent.balance= -1;
             return true;
         } else {
-            if (ASSERT) Assert.isTrue(false);
+            if cast(ASSERT) Assert.isTrue(false);
             return true;
         }
     }
@@ -1176,7 +1176,7 @@
             child= parent;
             parent= child.parent;
         }
-        if (ASSERT) Assert.isTrue(node.delimiter is NO_DELIM);
+        if cast(ASSERT) Assert.isTrue(node.delimiter is NO_DELIM);
         return null;
     }
 
@@ -1403,7 +1403,7 @@
     public String toString() {
         int depth= computeDepth(fRoot);
         int WIDTH= 30;
-        int leaves= (int) Math.pow(2, depth - 1);
+        int leaves= cast(int) Math.pow(2, depth - 1);
         int width= WIDTH * leaves;
         String empty= "."; //$NON-NLS-1$
         
@@ -1423,7 +1423,7 @@
                 // pad before
                 buf.append(space, 0, spaces);
                 
-                Node node= (Node) it.next();
+                Node node= cast(Node) it.next();
                 String box;
                 // replace the node with its children
                 if (node is null) {
@@ -1463,7 +1463,7 @@
         if (root is null)
             return 0;
         
-        return (byte) (Math.max(computeDepth(root.left), computeDepth(root.right)) + 1);
+        return cast(byte) (Math.max(computeDepth(root.left), computeDepth(root.right)) + 1);
     }
     
     /**
@@ -1497,7 +1497,7 @@
         Assert.isTrue(node.left is null || node.left.parent is node);
         Assert.isTrue(node.right is null || node.right.parent is node);
         
-        return (byte) (Math.max(rightDepth, leftDepth) + 1);
+        return cast(byte) (Math.max(rightDepth, leftDepth) + 1);
     }
     
     /**