Mercurial > projects > dwt-addons
comparison dwtx/text/edits/TextEdit.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 | 51e6e63f930e |
children | 93a6ec48fd28 |
comparison
equal
deleted
inserted
replaced
135:65801ad2b265 | 136:6dcb0baaa031 |
---|---|
123 * well formed. | 123 * well formed. |
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) { |
129 TextEdit edit1= cast(TextEdit)o1; | 129 TextEdit edit1= cast(TextEdit)o1; |
130 TextEdit edit2= cast(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(); |
355 * @exception MalformedTreeException is thrown if the child | 355 * @exception MalformedTreeException is thrown if the child |
356 * edit can't be added to this edit. This is the case if the child | 356 * edit can't be added to this edit. This is the case if the child |
357 * overlaps with one of its siblings or if the child edit's region | 357 * overlaps with one of its siblings or if the child edit's region |
358 * isn't fully covered by this edit. | 358 * isn't fully covered by this edit. |
359 */ | 359 */ |
360 public final void addChild(TextEdit child) throws MalformedTreeException { | 360 public final void addChild(TextEdit child) { |
361 internalAdd(child); | 361 internalAdd(child); |
362 } | 362 } |
363 | 363 |
364 /** | 364 /** |
365 * Adds all edits in <code>edits</code> to this edit. | 365 * Adds all edits in <code>edits</code> to this edit. |
368 * @exception MalformedTreeException is thrown if one of | 368 * @exception MalformedTreeException is thrown if one of |
369 * the given edits can't be added to this edit. | 369 * the given edits can't be added to this edit. |
370 * | 370 * |
371 * @see #addChild(TextEdit) | 371 * @see #addChild(TextEdit) |
372 */ | 372 */ |
373 public final void addChildren(TextEdit[] edits) throws MalformedTreeException { | 373 public final void addChildren(TextEdit[] edits) { |
374 for (int i= 0; i < edits.length; i++) { | 374 for (int i= 0; i < edits.length; i++) { |
375 internalAdd(edits[i]); | 375 internalAdd(edits[i]); |
376 } | 376 } |
377 } | 377 } |
378 | 378 |
758 */ | 758 */ |
759 public final UndoEdit apply(IDocument document) throws MalformedTreeException, BadLocationException { | 759 public final UndoEdit apply(IDocument document) throws MalformedTreeException, BadLocationException { |
760 return apply(document, CREATE_UNDO | UPDATE_REGIONS); | 760 return apply(document, CREATE_UNDO | UPDATE_REGIONS); |
761 } | 761 } |
762 | 762 |
763 UndoEdit dispatchPerformEdits(TextEditProcessor processor) throws BadLocationException { | 763 UndoEdit dispatchPerformEdits(TextEditProcessor processor) { |
764 return processor.executeDo(); | 764 return processor.executeDo(); |
765 } | 765 } |
766 | 766 |
767 void dispatchCheckIntegrity(TextEditProcessor processor) throws MalformedTreeException { | 767 void dispatchCheckIntegrity(TextEditProcessor processor) { |
768 processor.checkIntegrityDo(); | 768 processor.checkIntegrityDo(); |
769 } | 769 } |
770 | 770 |
771 //---- internal state accessors ---------------------------------------------------------- | 771 //---- internal state accessors ---------------------------------------------------------- |
772 | 772 |
792 | 792 |
793 void internalSetChildren(List children) { | 793 void internalSetChildren(List children) { |
794 fChildren= children; | 794 fChildren= children; |
795 } | 795 } |
796 | 796 |
797 void internalAdd(TextEdit child) throws MalformedTreeException { | 797 void internalAdd(TextEdit child) { |
798 child.aboutToBeAdded(this); | 798 child.aboutToBeAdded(this); |
799 if (child.isDeleted()) | 799 if (child.isDeleted()) |
800 throw new MalformedTreeException(this, child, TextEditMessages.getString("TextEdit.deleted_edit")); //$NON-NLS-1$ | 800 throw new MalformedTreeException(this, child, TextEditMessages.getString("TextEdit.deleted_edit")); //$NON-NLS-1$ |
801 if (!covers(child)) | 801 if (!covers(child)) |
802 throw new MalformedTreeException(this, child, TextEditMessages.getString("TextEdit.range_outside")); //$NON-NLS-1$ | 802 throw new MalformedTreeException(this, child, TextEditMessages.getString("TextEdit.range_outside")); //$NON-NLS-1$ |
806 int index= computeInsertionIndex(child); | 806 int index= computeInsertionIndex(child); |
807 fChildren.add(index, child); | 807 fChildren.add(index, child); |
808 child.internalSetParent(this); | 808 child.internalSetParent(this); |
809 } | 809 } |
810 | 810 |
811 private int computeInsertionIndex(TextEdit edit) throws MalformedTreeException { | 811 private int computeInsertionIndex(TextEdit edit) { |
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= cast(TextEdit)fChildren.get(lastIndex); | 816 TextEdit last= cast(TextEdit)fChildren.get(lastIndex); |
907 } | 907 } |
908 | 908 |
909 void performSourceComputation(TextEditProcessor processor, IDocument document) { | 909 void performSourceComputation(TextEditProcessor processor, IDocument document) { |
910 } | 910 } |
911 | 911 |
912 int traverseDocumentUpdating(TextEditProcessor processor, IDocument document) throws BadLocationException { | 912 int traverseDocumentUpdating(TextEditProcessor processor, IDocument document) { |
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= cast(TextEdit)fChildren.get(i); | 916 TextEdit child= cast(TextEdit)fChildren.get(i); |
917 delta+= child.traverseDocumentUpdating(processor, document); | 917 delta+= child.traverseDocumentUpdating(processor, document); |