Mercurial > projects > dwt-addons
comparison dwtx/jface/text/DocumentCommand.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 |
comparison
equal
deleted
inserted
replaced
133:7d818bd32d63 | 134:51e6e63f930e |
---|---|
246 */ | 246 */ |
247 public int compareTo(final Object object) { | 247 public int compareTo(final Object object) { |
248 if (isEqual(object)) | 248 if (isEqual(object)) |
249 return 0; | 249 return 0; |
250 | 250 |
251 final Command command= (Command) object; | 251 final Command command= cast(Command) object; |
252 | 252 |
253 // diff middle points if not intersecting | 253 // diff middle points if not intersecting |
254 if (fOffset + fLength <= command.fOffset || command.fOffset + command.fLength <= fOffset) { | 254 if (fOffset + fLength <= command.fOffset || command.fOffset + command.fLength <= fOffset) { |
255 int value= (2 * fOffset + fLength) - (2 * command.fOffset + command.fLength); | 255 int value= (2 * fOffset + fLength) - (2 * command.fOffset + command.fLength); |
256 if (value !is 0) | 256 if (value !is 0) |
263 private bool isEqual(Object object) { | 263 private bool isEqual(Object object) { |
264 if (object is this) | 264 if (object is this) |
265 return true; | 265 return true; |
266 if (!(object instanceof Command)) | 266 if (!(object instanceof Command)) |
267 return false; | 267 return false; |
268 final Command command= (Command) object; | 268 final Command command= cast(Command) object; |
269 return command.fOffset is fOffset && command.fLength is fLength; | 269 return command.fOffset is fOffset && command.fLength is fLength; |
270 } | 270 } |
271 } | 271 } |
272 | 272 |
273 /** | 273 /** |
361 final Command tempCommand= fCommand; | 361 final Command tempCommand= fCommand; |
362 fCommand= null; | 362 fCommand= null; |
363 return tempCommand; | 363 return tempCommand; |
364 } | 364 } |
365 | 365 |
366 final Command command= (Command) fIterator.next(); | 366 final Command command= cast(Command) fIterator.next(); |
367 final int compareValue= command.compareTo(fCommand); | 367 final int compareValue= command.compareTo(fCommand); |
368 | 368 |
369 if ((compareValue < 0) ^ !fForward) { | 369 if ((compareValue < 0) ^ !fForward) { |
370 return command; | 370 return command; |
371 | 371 |
484 | 484 |
485 // binary search result is defined as (-(insertionIndex) - 1) | 485 // binary search result is defined as (-(insertionIndex) - 1) |
486 final int insertionIndex= -(index + 1); | 486 final int insertionIndex= -(index + 1); |
487 | 487 |
488 // overlaps to the right? | 488 // overlaps to the right? |
489 if (insertionIndex !is fCommands.size() && intersects((Command) fCommands.get(insertionIndex), command)) | 489 if (insertionIndex !is fCommands.size() && intersects(cast(Command) fCommands.get(insertionIndex), command)) |
490 throw new BadLocationException(); | 490 throw new BadLocationException(); |
491 | 491 |
492 // overlaps to the left? | 492 // overlaps to the left? |
493 if (insertionIndex !is 0 && intersects((Command) fCommands.get(insertionIndex - 1), command)) | 493 if (insertionIndex !is 0 && intersects(cast(Command) fCommands.get(insertionIndex - 1), command)) |
494 throw new BadLocationException(); | 494 throw new BadLocationException(); |
495 | 495 |
496 fCommands.add(insertionIndex, command); | 496 fCommands.add(insertionIndex, command); |
497 } | 497 } |
498 | 498 |
569 document.addPosition(getCategory(), caretPosition); | 569 document.addPosition(getCategory(), caretPosition); |
570 } | 570 } |
571 | 571 |
572 final Command originalCommand= new Command(offset, length, text, owner); | 572 final Command originalCommand= new Command(offset, length, text, owner); |
573 for (final Iterator iterator= new CommandIterator(fCommands, originalCommand, false); iterator.hasNext(); ) | 573 for (final Iterator iterator= new CommandIterator(fCommands, originalCommand, false); iterator.hasNext(); ) |
574 ((Command) iterator.next()).execute(document); | 574 (cast(Command) iterator.next()).execute(document); |
575 | 575 |
576 } catch (BadLocationException e) { | 576 } catch (BadLocationException e) { |
577 // ignore | 577 // ignore |
578 } catch (BadPositionCategoryException e) { | 578 } catch (BadPositionCategoryException e) { |
579 // ignore | 579 // ignore |