Mercurial > projects > dwt-addons
comparison dwtx/jface/text/projection/ProjectionDocument.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 | b6bad70d540a |
comparison
equal
deleted
inserted
replaced
135:65801ad2b265 | 136:6dcb0baaa031 |
---|---|
296 * @param masterDocumentEvent the master document event that causes this | 296 * @param masterDocumentEvent the master document event that causes this |
297 * projection change or <code>null</code> if none | 297 * projection change or <code>null</code> if none |
298 * @throws BadLocationException if the given range is invalid in the master | 298 * @throws BadLocationException if the given range is invalid in the master |
299 * document | 299 * document |
300 */ | 300 */ |
301 private void internalAddMasterDocumentRange(int offsetInMaster, int lengthInMaster, DocumentEvent masterDocumentEvent) throws BadLocationException { | 301 private void internalAddMasterDocumentRange(int offsetInMaster, int lengthInMaster, DocumentEvent masterDocumentEvent) { |
302 if (lengthInMaster is 0) | 302 if (lengthInMaster is 0) |
303 return; | 303 return; |
304 | 304 |
305 try { | 305 try { |
306 | 306 |
403 * master document | 403 * master document |
404 * @throws IllegalArgumentException if the given range is not projected in | 404 * @throws IllegalArgumentException if the given range is not projected in |
405 * this projection document or is not completely comprised by | 405 * this projection document or is not completely comprised by |
406 * an existing fragment | 406 * an existing fragment |
407 */ | 407 */ |
408 private void internalRemoveMasterDocumentRange(int offsetInMaster, int lengthInMaster) throws BadLocationException { | 408 private void internalRemoveMasterDocumentRange(int offsetInMaster, int lengthInMaster) { |
409 try { | 409 try { |
410 | 410 |
411 IRegion imageRegion= fMapping.toExactImageRegion(new Region(offsetInMaster, lengthInMaster)); | 411 IRegion imageRegion= fMapping.toExactImageRegion(new Region(offsetInMaster, lengthInMaster)); |
412 if (imageRegion is null) | 412 if (imageRegion is null) |
413 throw new IllegalArgumentException(); | 413 throw new IllegalArgumentException(); |
468 * @return the sequence of regions which are not yet part of the projection | 468 * @return the sequence of regions which are not yet part of the projection |
469 * document | 469 * document |
470 * @throws BadLocationException in case the given range is invalid in the | 470 * @throws BadLocationException in case the given range is invalid in the |
471 * master document | 471 * master document |
472 */ | 472 */ |
473 public final IRegion[] computeUnprojectedMasterRegions(int offsetInMaster, int lengthInMaster) throws BadLocationException { | 473 public final IRegion[] computeUnprojectedMasterRegions(int offsetInMaster, int lengthInMaster) { |
474 | 474 |
475 IRegion[] fragments= null; | 475 IRegion[] fragments= null; |
476 IRegion imageRegion= fMapping.toImageRegion(new Region(offsetInMaster, lengthInMaster)); | 476 IRegion imageRegion= fMapping.toImageRegion(new Region(offsetInMaster, lengthInMaster)); |
477 if (imageRegion !is null) | 477 if (imageRegion !is null) |
478 fragments= fMapping.toExactOriginRegions(imageRegion); | 478 fragments= fMapping.toExactOriginRegions(imageRegion); |
515 * @return the first region that is not yet part of the projection document | 515 * @return the first region that is not yet part of the projection document |
516 * @throws BadLocationException in case the given range is invalid in the | 516 * @throws BadLocationException in case the given range is invalid in the |
517 * master document | 517 * master document |
518 * @since 3.1 | 518 * @since 3.1 |
519 */ | 519 */ |
520 private IRegion computeFirstUnprojectedMasterRegion(int offsetInMaster, int lengthInMaster) throws BadLocationException { | 520 private IRegion computeFirstUnprojectedMasterRegion(int offsetInMaster, int lengthInMaster) { |
521 | 521 |
522 IRegion[] fragments= null; | 522 IRegion[] fragments= null; |
523 IRegion imageRegion= fMapping.toImageRegion(new Region(offsetInMaster, lengthInMaster)); | 523 IRegion imageRegion= fMapping.toImageRegion(new Region(offsetInMaster, lengthInMaster)); |
524 if (imageRegion !is null) | 524 if (imageRegion !is null) |
525 fragments= fMapping.toExactOriginRegions(imageRegion); | 525 fragments= fMapping.toExactOriginRegions(imageRegion); |
554 * | 554 * |
555 * @param offsetInMaster the offset of the master document range | 555 * @param offsetInMaster the offset of the master document range |
556 * @param lengthInMaster the length of the master document range | 556 * @param lengthInMaster the length of the master document range |
557 * @throws BadLocationException in case the master event is not valid | 557 * @throws BadLocationException in case the master event is not valid |
558 */ | 558 */ |
559 public void addMasterDocumentRange(int offsetInMaster, int lengthInMaster) throws BadLocationException { | 559 public void addMasterDocumentRange(int offsetInMaster, int lengthInMaster) { |
560 addMasterDocumentRange(offsetInMaster, lengthInMaster, null); | 560 addMasterDocumentRange(offsetInMaster, lengthInMaster, null); |
561 } | 561 } |
562 | 562 |
563 /** | 563 /** |
564 * Ensures that the given range of the master document is part of this | 564 * Ensures that the given range of the master document is part of this |
568 * @param lengthInMaster the length of the master document range | 568 * @param lengthInMaster the length of the master document range |
569 * @param masterDocumentEvent the master document event which causes this | 569 * @param masterDocumentEvent the master document event which causes this |
570 * projection change, or <code>null</code> if none | 570 * projection change, or <code>null</code> if none |
571 * @throws BadLocationException in case the master event is not valid | 571 * @throws BadLocationException in case the master event is not valid |
572 */ | 572 */ |
573 private void addMasterDocumentRange(int offsetInMaster, int lengthInMaster, DocumentEvent masterDocumentEvent) throws BadLocationException { | 573 private void addMasterDocumentRange(int offsetInMaster, int lengthInMaster, DocumentEvent masterDocumentEvent) { |
574 /* | 574 /* |
575 * Calling internalAddMasterDocumentRange may cause other master ranges | 575 * Calling internalAddMasterDocumentRange may cause other master ranges |
576 * to become unfolded, resulting in re-entrant calls to this method. In | 576 * to become unfolded, resulting in re-entrant calls to this method. In |
577 * order to not add a region twice, we have to compute the next region | 577 * order to not add a region twice, we have to compute the next region |
578 * to add in every iteration. | 578 * to add in every iteration. |
599 * | 599 * |
600 * @param offsetInMaster the offset of the master document range | 600 * @param offsetInMaster the offset of the master document range |
601 * @param lengthInMaster the length of the master document range | 601 * @param lengthInMaster the length of the master document range |
602 * @throws BadLocationException in case the master event is not valid | 602 * @throws BadLocationException in case the master event is not valid |
603 */ | 603 */ |
604 public void removeMasterDocumentRange(int offsetInMaster, int lengthInMaster) throws BadLocationException { | 604 public void removeMasterDocumentRange(int offsetInMaster, int lengthInMaster) { |
605 IRegion[] fragments= computeProjectedMasterRegions(offsetInMaster, lengthInMaster); | 605 IRegion[] fragments= computeProjectedMasterRegions(offsetInMaster, lengthInMaster); |
606 if (fragments is null || fragments.length is 0) | 606 if (fragments is null || fragments.length is 0) |
607 return; | 607 return; |
608 | 608 |
609 for (int i= 0; i < fragments.length; i++) { | 609 for (int i= 0; i < fragments.length; i++) { |
620 * @param offsetInMaster the range offset in the master document | 620 * @param offsetInMaster the range offset in the master document |
621 * @param lengthInMaster the range length in the master document | 621 * @param lengthInMaster the range length in the master document |
622 * @return the sequence of regions which are part of the projection document or <code>null</code> | 622 * @return the sequence of regions which are part of the projection document or <code>null</code> |
623 * @throws BadLocationException in case the given range is invalid in the master document | 623 * @throws BadLocationException in case the given range is invalid in the master document |
624 */ | 624 */ |
625 public final IRegion[] computeProjectedMasterRegions(int offsetInMaster, int lengthInMaster) throws BadLocationException { | 625 public final IRegion[] computeProjectedMasterRegions(int offsetInMaster, int lengthInMaster) { |
626 IRegion imageRegion= fMapping.toImageRegion(new Region(offsetInMaster, lengthInMaster)); | 626 IRegion imageRegion= fMapping.toImageRegion(new Region(offsetInMaster, lengthInMaster)); |
627 return imageRegion !is null ? fMapping.toExactOriginRegions(imageRegion) : null; | 627 return imageRegion !is null ? fMapping.toExactOriginRegions(imageRegion) : null; |
628 } | 628 } |
629 | 629 |
630 /** | 630 /** |
637 } | 637 } |
638 | 638 |
639 /* | 639 /* |
640 * @see dwtx.jface.text.IDocument#replace(int, int, java.lang.String) | 640 * @see dwtx.jface.text.IDocument#replace(int, int, java.lang.String) |
641 */ | 641 */ |
642 public void replace(int offset, int length, String text) throws BadLocationException { | 642 public void replace(int offset, int length, String text) { |
643 try { | 643 try { |
644 fIsUpdating= true; | 644 fIsUpdating= true; |
645 if (fMasterDocumentExtension !is null) | 645 if (fMasterDocumentExtension !is null) |
646 fMasterDocumentExtension.stopPostNotificationProcessing(); | 646 fMasterDocumentExtension.stopPostNotificationProcessing(); |
647 | 647 |
678 * | 678 * |
679 * @param masterEvent the master document event | 679 * @param masterEvent the master document event |
680 * @return the slave document event | 680 * @return the slave document event |
681 * @throws BadLocationException in case the master event is not valid | 681 * @throws BadLocationException in case the master event is not valid |
682 */ | 682 */ |
683 private ProjectionDocumentEvent normalize(DocumentEvent masterEvent) throws BadLocationException { | 683 private ProjectionDocumentEvent normalize(DocumentEvent masterEvent) { |
684 if (!isUpdating()) { | 684 if (!isUpdating()) { |
685 IRegion imageRegion= fMapping.toExactImageRegion(new Region(masterEvent.getOffset(), masterEvent.getLength())); | 685 IRegion imageRegion= fMapping.toExactImageRegion(new Region(masterEvent.getOffset(), masterEvent.getLength())); |
686 if (imageRegion !is null) | 686 if (imageRegion !is null) |
687 return new ProjectionDocumentEvent(this, imageRegion.getOffset(), imageRegion.getLength(), masterEvent.getText(), masterEvent); | 687 return new ProjectionDocumentEvent(this, imageRegion.getOffset(), imageRegion.getLength(), masterEvent.getText(), masterEvent); |
688 return null; | 688 return null; |
699 * | 699 * |
700 * @param masterEvent the master document event | 700 * @param masterEvent the master document event |
701 * @return <code>true</code> if masterEvent affects this projection document | 701 * @return <code>true</code> if masterEvent affects this projection document |
702 * @throws BadLocationException in case the master event is not valid | 702 * @throws BadLocationException in case the master event is not valid |
703 */ | 703 */ |
704 protected final bool adaptProjectionToMasterChange(DocumentEvent masterEvent) throws BadLocationException { | 704 protected final bool adaptProjectionToMasterChange(DocumentEvent masterEvent) { |
705 if (!isUpdating() && fFragmentsUpdater.affectsPositions(masterEvent) || fIsAutoExpanding && masterEvent.getLength() > 0) { | 705 if (!isUpdating() && fFragmentsUpdater.affectsPositions(masterEvent) || fIsAutoExpanding && masterEvent.getLength() > 0) { |
706 | 706 |
707 addMasterDocumentRange(masterEvent.getOffset(), masterEvent.getLength(), masterEvent); | 707 addMasterDocumentRange(masterEvent.getOffset(), masterEvent.getLength(), masterEvent); |
708 return true; | 708 return true; |
709 | 709 |
889 * | 889 * |
890 * @param offsetInMaster the offset in the master document | 890 * @param offsetInMaster the offset in the master document |
891 * @param lengthInMaster the length in the master document | 891 * @param lengthInMaster the length in the master document |
892 * @throws BadLocationException if the given range of the master document is not valid | 892 * @throws BadLocationException if the given range of the master document is not valid |
893 */ | 893 */ |
894 public void replaceMasterDocumentRanges(int offsetInMaster, int lengthInMaster) throws BadLocationException { | 894 public void replaceMasterDocumentRanges(int offsetInMaster, int lengthInMaster) { |
895 try { | 895 try { |
896 | 896 |
897 ProjectionDocumentEvent event= new ProjectionDocumentEvent(this, 0, fMapping.getImageLength(), fMasterDocument.get(offsetInMaster, lengthInMaster), offsetInMaster, lengthInMaster); | 897 ProjectionDocumentEvent event= new ProjectionDocumentEvent(this, 0, fMapping.getImageLength(), fMasterDocument.get(offsetInMaster, lengthInMaster), offsetInMaster, lengthInMaster); |
898 super.fireDocumentAboutToBeChanged(event); | 898 super.fireDocumentAboutToBeChanged(event); |
899 | 899 |