Mercurial > projects > dwt-addons
comparison dwtx/text/edits/TextEdit.d @ 134:51e6e63f930e
Regex fix for casts
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 24 Aug 2008 01:46:20 +0200 |
parents | c4fb132a086c |
children | 6dcb0baaa031 |
comparison
equal
deleted
inserted
replaced
133:7d818bd32d63 | 134:51e6e63f930e |
---|---|
124 */ | 124 */ |
125 public static final int UPDATE_REGIONS= 1 << 1; | 125 public static final int UPDATE_REGIONS= 1 << 1; |
126 | 126 |
127 private static class InsertionComparator : Comparator { | 127 private static class InsertionComparator : Comparator { |
128 public int compare(Object o1, Object o2) throws MalformedTreeException { | 128 public int compare(Object o1, Object o2) throws MalformedTreeException { |
129 TextEdit edit1= (TextEdit)o1; | 129 TextEdit edit1= cast(TextEdit)o1; |
130 TextEdit edit2= (TextEdit)o2; | 130 TextEdit edit2= cast(TextEdit)o2; |
131 | 131 |
132 int offset1= edit1.getOffset(); | 132 int offset1= edit1.getOffset(); |
133 int length1= edit1.getLength(); | 133 int length1= edit1.getLength(); |
134 | 134 |
135 int offset2= edit2.getOffset(); | 135 int offset2= edit2.getOffset(); |
388 * is out of range | 388 * is out of range |
389 */ | 389 */ |
390 public final TextEdit removeChild(int index) { | 390 public final TextEdit removeChild(int index) { |
391 if (fChildren is null) | 391 if (fChildren is null) |
392 throw new IndexOutOfBoundsException("Index: " + index + " Size: 0"); //$NON-NLS-1$//$NON-NLS-2$ | 392 throw new IndexOutOfBoundsException("Index: " + index + " Size: 0"); //$NON-NLS-1$//$NON-NLS-2$ |
393 TextEdit result= (TextEdit)fChildren.remove(index); | 393 TextEdit result= cast(TextEdit)fChildren.remove(index); |
394 result.internalSetParent(null); | 394 result.internalSetParent(null); |
395 if (fChildren.isEmpty()) | 395 if (fChildren.isEmpty()) |
396 fChildren= null; | 396 fChildren= null; |
397 return result; | 397 return result; |
398 } | 398 } |
428 if (fChildren is null) | 428 if (fChildren is null) |
429 return EMPTY_ARRAY; | 429 return EMPTY_ARRAY; |
430 int size= fChildren.size(); | 430 int size= fChildren.size(); |
431 TextEdit[] result= new TextEdit[size]; | 431 TextEdit[] result= new TextEdit[size]; |
432 for (int i= 0; i < size; i++) { | 432 for (int i= 0; i < size; i++) { |
433 result[i]= (TextEdit)fChildren.get(i); | 433 result[i]= cast(TextEdit)fChildren.get(i); |
434 result[i].internalSetParent(null); | 434 result[i].internalSetParent(null); |
435 } | 435 } |
436 fChildren= null; | 436 fChildren= null; |
437 return result; | 437 return result; |
438 } | 438 } |
589 */ | 589 */ |
590 private void toStringWithChildren(StringBuffer buffer, int indent) { | 590 private void toStringWithChildren(StringBuffer buffer, int indent) { |
591 internalToString(buffer, indent); | 591 internalToString(buffer, indent); |
592 if (fChildren !is null) { | 592 if (fChildren !is null) { |
593 for (Iterator iterator= fChildren.iterator(); iterator.hasNext();) { | 593 for (Iterator iterator= fChildren.iterator(); iterator.hasNext();) { |
594 TextEdit child= (TextEdit) iterator.next(); | 594 TextEdit child= cast(TextEdit) iterator.next(); |
595 buffer.append('\n'); | 595 buffer.append('\n'); |
596 child.toStringWithChildren(buffer, indent + 1); | 596 child.toStringWithChildren(buffer, indent + 1); |
597 } | 597 } |
598 } | 598 } |
599 } | 599 } |
700 protected final void acceptChildren(TextEditVisitor visitor) { | 700 protected final void acceptChildren(TextEditVisitor visitor) { |
701 if (fChildren is null) | 701 if (fChildren is null) |
702 return; | 702 return; |
703 Iterator iterator= fChildren.iterator(); | 703 Iterator iterator= fChildren.iterator(); |
704 while (iterator.hasNext()) { | 704 while (iterator.hasNext()) { |
705 TextEdit curr= (TextEdit) iterator.next(); | 705 TextEdit curr= cast(TextEdit) iterator.next(); |
706 curr.accept(visitor); | 706 curr.accept(visitor); |
707 } | 707 } |
708 } | 708 } |
709 | 709 |
710 //---- Execution ------------------------------------------------------- | 710 //---- Execution ------------------------------------------------------- |
811 private int computeInsertionIndex(TextEdit edit) throws MalformedTreeException { | 811 private int computeInsertionIndex(TextEdit edit) throws MalformedTreeException { |
812 int size= fChildren.size(); | 812 int size= fChildren.size(); |
813 if (size is 0) | 813 if (size is 0) |
814 return 0; | 814 return 0; |
815 int lastIndex= size - 1; | 815 int lastIndex= size - 1; |
816 TextEdit last= (TextEdit)fChildren.get(lastIndex); | 816 TextEdit last= cast(TextEdit)fChildren.get(lastIndex); |
817 if (last.getExclusiveEnd() <= edit.getOffset()) | 817 if (last.getExclusiveEnd() <= edit.getOffset()) |
818 return size; | 818 return size; |
819 try { | 819 try { |
820 | 820 |
821 int index= Collections.binarySearch(fChildren, edit, INSERTION_COMPARATOR); | 821 int index= Collections.binarySearch(fChildren, edit, INSERTION_COMPARATOR); |
888 */ | 888 */ |
889 int traverseConsistencyCheck(TextEditProcessor processor, IDocument document, List sourceEdits) { | 889 int traverseConsistencyCheck(TextEditProcessor processor, IDocument document, List sourceEdits) { |
890 int result= 0; | 890 int result= 0; |
891 if (fChildren !is null) { | 891 if (fChildren !is null) { |
892 for (int i= fChildren.size() - 1; i >= 0; i--) { | 892 for (int i= fChildren.size() - 1; i >= 0; i--) { |
893 TextEdit child= (TextEdit)fChildren.get(i); | 893 TextEdit child= cast(TextEdit)fChildren.get(i); |
894 result= Math.max(result, child.traverseConsistencyCheck(processor, document, sourceEdits)); | 894 result= Math.max(result, child.traverseConsistencyCheck(processor, document, sourceEdits)); |
895 } | 895 } |
896 } | 896 } |
897 if (processor.considerEdit(this)) { | 897 if (processor.considerEdit(this)) { |
898 performConsistencyCheck(processor, document); | 898 performConsistencyCheck(processor, document); |
911 | 911 |
912 int traverseDocumentUpdating(TextEditProcessor processor, IDocument document) throws BadLocationException { | 912 int traverseDocumentUpdating(TextEditProcessor processor, IDocument document) throws BadLocationException { |
913 int delta= 0; | 913 int delta= 0; |
914 if (fChildren !is null) { | 914 if (fChildren !is null) { |
915 for (int i= fChildren.size() - 1; i >= 0; i--) { | 915 for (int i= fChildren.size() - 1; i >= 0; i--) { |
916 TextEdit child= (TextEdit)fChildren.get(i); | 916 TextEdit child= cast(TextEdit)fChildren.get(i); |
917 delta+= child.traverseDocumentUpdating(processor, document); | 917 delta+= child.traverseDocumentUpdating(processor, document); |
918 childDocumentUpdated(); | 918 childDocumentUpdated(); |
919 } | 919 } |
920 } | 920 } |
921 if (processor.considerEdit(this)) { | 921 if (processor.considerEdit(this)) { |
947 int traverseRegionUpdating(TextEditProcessor processor, IDocument document, int accumulatedDelta, bool delete) { | 947 int traverseRegionUpdating(TextEditProcessor processor, IDocument document, int accumulatedDelta, bool delete) { |
948 performRegionUpdating(accumulatedDelta, delete); | 948 performRegionUpdating(accumulatedDelta, delete); |
949 if (fChildren !is null) { | 949 if (fChildren !is null) { |
950 bool childDelete= delete || deleteChildren(); | 950 bool childDelete= delete || deleteChildren(); |
951 for (Iterator iter= fChildren.iterator(); iter.hasNext();) { | 951 for (Iterator iter= fChildren.iterator(); iter.hasNext();) { |
952 TextEdit child= (TextEdit)iter.next(); | 952 TextEdit child= cast(TextEdit)iter.next(); |
953 accumulatedDelta= child.traverseRegionUpdating(processor, document, accumulatedDelta, childDelete); | 953 accumulatedDelta= child.traverseRegionUpdating(processor, document, accumulatedDelta, childDelete); |
954 childRegionUpdated(); | 954 childRegionUpdated(); |
955 } | 955 } |
956 } | 956 } |
957 return accumulatedDelta + fDelta; | 957 return accumulatedDelta + fDelta; |
983 | 983 |
984 void internalMoveTree(int delta) { | 984 void internalMoveTree(int delta) { |
985 adjustOffset(delta); | 985 adjustOffset(delta); |
986 if (fChildren !is null) { | 986 if (fChildren !is null) { |
987 for (Iterator iter= fChildren.iterator(); iter.hasNext();) { | 987 for (Iterator iter= fChildren.iterator(); iter.hasNext();) { |
988 ((TextEdit)iter.next()).internalMoveTree(delta); | 988 (cast(TextEdit)iter.next()).internalMoveTree(delta); |
989 } | 989 } |
990 } | 990 } |
991 } | 991 } |
992 | 992 |
993 void deleteTree() { | 993 void deleteTree() { |
994 markAsDeleted(); | 994 markAsDeleted(); |
995 if (fChildren !is null) { | 995 if (fChildren !is null) { |
996 for (Iterator iter= fChildren.iterator(); iter.hasNext();) { | 996 for (Iterator iter= fChildren.iterator(); iter.hasNext();) { |
997 TextEdit child= (TextEdit)iter.next(); | 997 TextEdit child= cast(TextEdit)iter.next(); |
998 child.deleteTree(); | 998 child.deleteTree(); |
999 } | 999 } |
1000 } | 1000 } |
1001 } | 1001 } |
1002 } | 1002 } |