comparison dwtx/jface/text/source/projection/ProjectionViewer.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 65801ad2b265
comparison
equal deleted inserted replaced
133:7d818bd32d63 134:51e6e63f930e
274 fExpectedExecutionCosts= fList.size(); 274 fExpectedExecutionCosts= fList.size();
275 if (fExpectedExecutionCosts <= max_costs) { 275 if (fExpectedExecutionCosts <= max_costs) {
276 ProjectionCommand command; 276 ProjectionCommand command;
277 Iterator e= fList.iterator(); 277 Iterator e= fList.iterator();
278 while (e.hasNext()) { 278 while (e.hasNext()) {
279 command= (ProjectionCommand) e.next(); 279 command= cast(ProjectionCommand) e.next();
280 fExpectedExecutionCosts += command.computeExpectedCosts(); 280 fExpectedExecutionCosts += command.computeExpectedCosts();
281 if (fExpectedExecutionCosts > max_costs) 281 if (fExpectedExecutionCosts > max_costs)
282 break; 282 break;
283 } 283 }
284 } 284 }
342 * 342 *
343 * @param model the model to which the projection annotation model is added 343 * @param model the model to which the projection annotation model is added
344 */ 344 */
345 private void addProjectionAnnotationModel(IAnnotationModel model) { 345 private void addProjectionAnnotationModel(IAnnotationModel model) {
346 if (model instanceof IAnnotationModelExtension) { 346 if (model instanceof IAnnotationModelExtension) {
347 IAnnotationModelExtension extension= (IAnnotationModelExtension) model; 347 IAnnotationModelExtension extension= cast(IAnnotationModelExtension) model;
348 extension.addAnnotationModel(ProjectionSupport.PROJECTION, fProjectionAnnotationModel); 348 extension.addAnnotationModel(ProjectionSupport.PROJECTION, fProjectionAnnotationModel);
349 model.addAnnotationModelListener(fAnnotationModelListener); 349 model.addAnnotationModelListener(fAnnotationModelListener);
350 } 350 }
351 } 351 }
352 352
357 * @return the removed projection annotation model or <code>null</code> if there was none 357 * @return the removed projection annotation model or <code>null</code> if there was none
358 */ 358 */
359 private IAnnotationModel removeProjectionAnnotationModel(IAnnotationModel model) { 359 private IAnnotationModel removeProjectionAnnotationModel(IAnnotationModel model) {
360 if (model instanceof IAnnotationModelExtension) { 360 if (model instanceof IAnnotationModelExtension) {
361 model.removeAnnotationModelListener(fAnnotationModelListener); 361 model.removeAnnotationModelListener(fAnnotationModelListener);
362 IAnnotationModelExtension extension= (IAnnotationModelExtension) model; 362 IAnnotationModelExtension extension= cast(IAnnotationModelExtension) model;
363 return extension.removeAnnotationModel(ProjectionSupport.PROJECTION); 363 return extension.removeAnnotationModel(ProjectionSupport.PROJECTION);
364 } 364 }
365 return null; 365 return null;
366 } 366 }
367 367
401 * @return the projection annotation model 401 * @return the projection annotation model
402 */ 402 */
403 public ProjectionAnnotationModel getProjectionAnnotationModel() { 403 public ProjectionAnnotationModel getProjectionAnnotationModel() {
404 IAnnotationModel model= getVisualAnnotationModel(); 404 IAnnotationModel model= getVisualAnnotationModel();
405 if (model instanceof IAnnotationModelExtension) { 405 if (model instanceof IAnnotationModelExtension) {
406 IAnnotationModelExtension extension= (IAnnotationModelExtension) model; 406 IAnnotationModelExtension extension= cast(IAnnotationModelExtension) model;
407 return (ProjectionAnnotationModel) extension.getAnnotationModel(ProjectionSupport.PROJECTION); 407 return cast(ProjectionAnnotationModel) extension.getAnnotationModel(ProjectionSupport.PROJECTION);
408 } 408 }
409 return null; 409 return null;
410 } 410 }
411 411
412 /* 412 /*
419 /* 419 /*
420 * @see dwtx.jface.text.TextViewer#updateSlaveDocument(dwtx.jface.text.IDocument, int, int) 420 * @see dwtx.jface.text.TextViewer#updateSlaveDocument(dwtx.jface.text.IDocument, int, int)
421 */ 421 */
422 protected bool updateSlaveDocument(IDocument slaveDocument, int modelRangeOffset, int modelRangeLength) throws BadLocationException { 422 protected bool updateSlaveDocument(IDocument slaveDocument, int modelRangeOffset, int modelRangeLength) throws BadLocationException {
423 if (slaveDocument instanceof ProjectionDocument) { 423 if (slaveDocument instanceof ProjectionDocument) {
424 ProjectionDocument projection= (ProjectionDocument) slaveDocument; 424 ProjectionDocument projection= cast(ProjectionDocument) slaveDocument;
425 425
426 int offset= modelRangeOffset; 426 int offset= modelRangeOffset;
427 int length= modelRangeLength; 427 int length= modelRangeLength;
428 428
429 if (!isProjectionMode()) { 429 if (!isProjectionMode()) {
488 */ 488 */
489 protected void fireProjectionEnabled() { 489 protected void fireProjectionEnabled() {
490 if (fProjectionListeners !is null) { 490 if (fProjectionListeners !is null) {
491 Iterator e= new ArrayList(fProjectionListeners).iterator(); 491 Iterator e= new ArrayList(fProjectionListeners).iterator();
492 while (e.hasNext()) { 492 while (e.hasNext()) {
493 IProjectionListener l= (IProjectionListener) e.next(); 493 IProjectionListener l= cast(IProjectionListener) e.next();
494 l.projectionEnabled(); 494 l.projectionEnabled();
495 } 495 }
496 } 496 }
497 } 497 }
498 498
502 */ 502 */
503 protected void fireProjectionDisabled() { 503 protected void fireProjectionDisabled() {
504 if (fProjectionListeners !is null) { 504 if (fProjectionListeners !is null) {
505 Iterator e= new ArrayList(fProjectionListeners).iterator(); 505 Iterator e= new ArrayList(fProjectionListeners).iterator();
506 while (e.hasNext()) { 506 while (e.hasNext()) {
507 IProjectionListener l= (IProjectionListener) e.next(); 507 IProjectionListener l= cast(IProjectionListener) e.next();
508 l.projectionDisabled(); 508 l.projectionDisabled();
509 } 509 }
510 } 510 }
511 } 511 }
512 512
556 if (isProjectionMode()) { 556 if (isProjectionMode()) {
557 Position found= null; 557 Position found= null;
558 Annotation bestMatch= null; 558 Annotation bestMatch= null;
559 Point selection= getSelectedRange(); 559 Point selection= getSelectedRange();
560 for (Iterator e= fProjectionAnnotationModel.getAnnotationIterator(); e.hasNext();) { 560 for (Iterator e= fProjectionAnnotationModel.getAnnotationIterator(); e.hasNext();) {
561 ProjectionAnnotation annotation= (ProjectionAnnotation) e.next(); 561 ProjectionAnnotation annotation= cast(ProjectionAnnotation) e.next();
562 if (annotation.isCollapsed()) { 562 if (annotation.isCollapsed()) {
563 Position position= fProjectionAnnotationModel.getPosition(annotation); 563 Position position= fProjectionAnnotationModel.getPosition(annotation);
564 // take the first most fine grained match 564 // take the first most fine grained match
565 if (position !is null && touches(selection, position)) 565 if (position !is null && touches(selection, position))
566 if (found is null || position.includes(found.offset) && position.includes(found.offset + found.length)) { 566 if (found is null || position.includes(found.offset) && position.includes(found.offset + found.length)) {
585 if (isProjectionMode()) { 585 if (isProjectionMode()) {
586 Position found= null; 586 Position found= null;
587 Annotation bestMatch= null; 587 Annotation bestMatch= null;
588 Point selection= getSelectedRange(); 588 Point selection= getSelectedRange();
589 for (Iterator e= fProjectionAnnotationModel.getAnnotationIterator(); e.hasNext();) { 589 for (Iterator e= fProjectionAnnotationModel.getAnnotationIterator(); e.hasNext();) {
590 ProjectionAnnotation annotation= (ProjectionAnnotation) e.next(); 590 ProjectionAnnotation annotation= cast(ProjectionAnnotation) e.next();
591 if (!annotation.isCollapsed()) { 591 if (!annotation.isCollapsed()) {
592 Position position= fProjectionAnnotationModel.getPosition(annotation); 592 Position position= fProjectionAnnotationModel.getPosition(annotation);
593 // take the first most fine grained match 593 // take the first most fine grained match
594 if (position !is null && touches(selection, position)) 594 if (position !is null && touches(selection, position))
595 if (found is null || found.includes(position.offset) && found.includes(position.offset + position.length)) { 595 if (found is null || found.includes(position.offset) && found.includes(position.offset + position.length)) {
804 private void collapse(int offset, int length, bool fireRedraw) throws BadLocationException { 804 private void collapse(int offset, int length, bool fireRedraw) throws BadLocationException {
805 ProjectionDocument projection= null; 805 ProjectionDocument projection= null;
806 806
807 IDocument visibleDocument= getVisibleDocument(); 807 IDocument visibleDocument= getVisibleDocument();
808 if (visibleDocument instanceof ProjectionDocument) 808 if (visibleDocument instanceof ProjectionDocument)
809 projection= (ProjectionDocument) visibleDocument; 809 projection= cast(ProjectionDocument) visibleDocument;
810 else { 810 else {
811 IDocument master= getDocument(); 811 IDocument master= getDocument();
812 IDocument slave= createSlaveDocument(getDocument()); 812 IDocument slave= createSlaveDocument(getDocument());
813 if (slave instanceof ProjectionDocument) { 813 if (slave instanceof ProjectionDocument) {
814 projection= (ProjectionDocument) slave; 814 projection= cast(ProjectionDocument) slave;
815 addMasterDocumentRange(projection, 0, master.getLength()); 815 addMasterDocumentRange(projection, 0, master.getLength());
816 replaceVisibleDocument(projection); 816 replaceVisibleDocument(projection);
817 } 817 }
818 } 818 }
819 819
842 * @throws BadLocationException in case the range is invalid 842 * @throws BadLocationException in case the range is invalid
843 */ 843 */
844 private void expand(int offset, int length, bool fireRedraw) throws BadLocationException { 844 private void expand(int offset, int length, bool fireRedraw) throws BadLocationException {
845 IDocument slave= getVisibleDocument(); 845 IDocument slave= getVisibleDocument();
846 if (slave instanceof ProjectionDocument) { 846 if (slave instanceof ProjectionDocument) {
847 ProjectionDocument projection= (ProjectionDocument) slave; 847 ProjectionDocument projection= cast(ProjectionDocument) slave;
848 848
849 // expand 849 // expand
850 addMasterDocumentRange(projection, offset, length); 850 addMasterDocumentRange(projection, offset, length);
851 851
852 // collapse contained regions 852 // collapse contained regions
912 while (true) { 912 while (true) {
913 AnnotationModelEvent ame= null; 913 AnnotationModelEvent ame= null;
914 synchronized (fLock) { 914 synchronized (fLock) {
915 if (fPendingRequests.size() is 0) 915 if (fPendingRequests.size() is 0)
916 return; 916 return;
917 ame= (AnnotationModelEvent) fPendingRequests.remove(0); 917 ame= cast(AnnotationModelEvent) fPendingRequests.remove(0);
918 } 918 }
919 catchupWithProjectionAnnotationModel(ame); 919 catchupWithProjectionAnnotationModel(ame);
920 } 920 }
921 } catch (BadLocationException x) { 921 } catch (BadLocationException x) {
922 try { 922 try {
945 * identical to this viewer's document 945 * identical to this viewer's document
946 * @since 3.1 946 * @since 3.1
947 */ 947 */
948 private bool isVisibleMasterDocumentSameAsDocument() { 948 private bool isVisibleMasterDocumentSameAsDocument() {
949 IDocument visibleDocument= getVisibleDocument(); 949 IDocument visibleDocument= getVisibleDocument();
950 return (visibleDocument instanceof ProjectionDocument) && ((ProjectionDocument)visibleDocument).getMasterDocument() is getDocument(); 950 return (visibleDocument instanceof ProjectionDocument) && (cast(ProjectionDocument)visibleDocument).getMasterDocument() is getDocument();
951 } 951 }
952 952
953 /** 953 /**
954 * Adapts the slave visual document of this viewer to the changes described 954 * Adapts the slave visual document of this viewer to the changes described
955 * in the annotation model event. When the event is <code>null</code>, 955 * in the annotation model event. When the event is <code>null</code>,
1022 private void executeProjectionCommands(ProjectionCommandQueue commandQueue, bool fireRedraw) throws BadLocationException { 1022 private void executeProjectionCommands(ProjectionCommandQueue commandQueue, bool fireRedraw) throws BadLocationException {
1023 1023
1024 ProjectionCommand command; 1024 ProjectionCommand command;
1025 Iterator e= commandQueue.iterator(); 1025 Iterator e= commandQueue.iterator();
1026 while (e.hasNext()) { 1026 while (e.hasNext()) {
1027 command= (ProjectionCommand) e.next(); 1027 command= cast(ProjectionCommand) e.next();
1028 switch (command.fType) { 1028 switch (command.fType) {
1029 case ProjectionCommand.ADD: 1029 case ProjectionCommand.ADD:
1030 addMasterDocumentRange(command.fProjection, command.fOffset, command.fLength); 1030 addMasterDocumentRange(command.fProjection, command.fOffset, command.fLength);
1031 break; 1031 break;
1032 case ProjectionCommand.REMOVE: 1032 case ProjectionCommand.REMOVE:
1050 1050
1051 private ProjectionAnnotation[] computeCollapsedNestedAnnotations(int offset, int length) { 1051 private ProjectionAnnotation[] computeCollapsedNestedAnnotations(int offset, int length) {
1052 List annotations= new ArrayList(5); 1052 List annotations= new ArrayList(5);
1053 Iterator e= fProjectionAnnotationModel.getAnnotationIterator(); 1053 Iterator e= fProjectionAnnotationModel.getAnnotationIterator();
1054 while (e.hasNext()) { 1054 while (e.hasNext()) {
1055 ProjectionAnnotation annotation= (ProjectionAnnotation) e.next(); 1055 ProjectionAnnotation annotation= cast(ProjectionAnnotation) e.next();
1056 if (annotation.isCollapsed()) { 1056 if (annotation.isCollapsed()) {
1057 Position position= fProjectionAnnotationModel.getPosition(annotation); 1057 Position position= fProjectionAnnotationModel.getPosition(annotation);
1058 if (position is null) { 1058 if (position is null) {
1059 // annotation might already be deleted, we will be informed later on about this deletion 1059 // annotation might already be deleted, we will be informed later on about this deletion
1060 continue; 1060 continue;
1084 /* 1084 /*
1085 * We pass the removed annotation into this method for performance reasons only. Otherwise, they could be fetch from the event. 1085 * We pass the removed annotation into this method for performance reasons only. Otherwise, they could be fetch from the event.
1086 */ 1086 */
1087 private void processDeletions(AnnotationModelEvent event, Annotation[] removedAnnotations, bool fireRedraw) throws BadLocationException { 1087 private void processDeletions(AnnotationModelEvent event, Annotation[] removedAnnotations, bool fireRedraw) throws BadLocationException {
1088 for (int i= 0; i < removedAnnotations.length; i++) { 1088 for (int i= 0; i < removedAnnotations.length; i++) {
1089 ProjectionAnnotation annotation= (ProjectionAnnotation) removedAnnotations[i]; 1089 ProjectionAnnotation annotation= cast(ProjectionAnnotation) removedAnnotations[i];
1090 if (annotation.isCollapsed()) { 1090 if (annotation.isCollapsed()) {
1091 Position expanded= event.getPositionOfRemovedAnnotation(annotation); 1091 Position expanded= event.getPositionOfRemovedAnnotation(annotation);
1092 expand(expanded.getOffset(), expanded.getLength(), fireRedraw); 1092 expand(expanded.getOffset(), expanded.getLength(), fireRedraw);
1093 } 1093 }
1094 } 1094 }
1133 IDocument document= getDocument(); 1133 IDocument document= getDocument();
1134 if (document is null) 1134 if (document is null)
1135 return null; 1135 return null;
1136 1136
1137 if (position instanceof IProjectionPosition) { 1137 if (position instanceof IProjectionPosition) {
1138 IProjectionPosition projPosition= (IProjectionPosition) position; 1138 IProjectionPosition projPosition= cast(IProjectionPosition) position;
1139 return projPosition.computeProjectionRegions(document); 1139 return projPosition.computeProjectionRegions(document);
1140 } 1140 }
1141 1141
1142 int line= document.getLineOfOffset(position.getOffset()); 1142 int line= document.getLineOfOffset(position.getOffset());
1143 int offset= document.getLineOffset(line + 1); 1143 int offset= document.getLineOffset(line + 1);
1167 if (document is null) 1167 if (document is null)
1168 return null; 1168 return null;
1169 1169
1170 int captionOffset= position.getOffset(); 1170 int captionOffset= position.getOffset();
1171 if (position instanceof IProjectionPosition) 1171 if (position instanceof IProjectionPosition)
1172 captionOffset+= ((IProjectionPosition) position).computeCaptionOffset(document); 1172 captionOffset+= (cast(IProjectionPosition) position).computeCaptionOffset(document);
1173 1173
1174 IRegion lineInfo= document.getLineInformationOfOffset(captionOffset); 1174 IRegion lineInfo= document.getLineInformationOfOffset(captionOffset);
1175 return new Position(lineInfo.getOffset() + lineInfo.getLength(), 0); 1175 return new Position(lineInfo.getOffset() + lineInfo.getLength(), 0);
1176 } catch (BadLocationException x) { 1176 } catch (BadLocationException x) {
1177 } 1177 }
1178 return null; 1178 return null;
1179 } 1179 }
1180 1180
1181 private void processChanges(Annotation[] annotations, bool fireRedraw, List coverage) throws BadLocationException { 1181 private void processChanges(Annotation[] annotations, bool fireRedraw, List coverage) throws BadLocationException {
1182 for (int i= 0; i < annotations.length; i++) { 1182 for (int i= 0; i < annotations.length; i++) {
1183 ProjectionAnnotation annotation= (ProjectionAnnotation) annotations[i]; 1183 ProjectionAnnotation annotation= cast(ProjectionAnnotation) annotations[i];
1184 Position position= fProjectionAnnotationModel.getPosition(annotation); 1184 Position position= fProjectionAnnotationModel.getPosition(annotation);
1185 1185
1186 if (position is null) 1186 if (position is null)
1187 continue; 1187 continue;
1188 1188
1201 } 1201 }
1202 1202
1203 private bool covers(List coverage, Position position) { 1203 private bool covers(List coverage, Position position) {
1204 Iterator e= coverage.iterator(); 1204 Iterator e= coverage.iterator();
1205 while (e.hasNext()) { 1205 while (e.hasNext()) {
1206 Position p= (Position) e.next(); 1206 Position p= cast(Position) e.next();
1207 if (p.getOffset() <= position.getOffset() && position.getOffset() + position.getLength() <= p.getOffset() + p.getLength()) 1207 if (p.getOffset() <= position.getOffset() && position.getOffset() + position.getLength() <= p.getOffset() + p.getLength())
1208 return true; 1208 return true;
1209 } 1209 }
1210 return false; 1210 return false;
1211 } 1211 }
1224 if (manager !is null) { 1224 if (manager !is null) {
1225 IDocument master= getDocument(); 1225 IDocument master= getDocument();
1226 if (master !is null) { 1226 if (master !is null) {
1227 IDocument slave= manager.createSlaveDocument(master); 1227 IDocument slave= manager.createSlaveDocument(master);
1228 if (slave instanceof ProjectionDocument) { 1228 if (slave instanceof ProjectionDocument) {
1229 projection= (ProjectionDocument) slave; 1229 projection= cast(ProjectionDocument) slave;
1230 addMasterDocumentRange(projection, 0, master.getLength()); 1230 addMasterDocumentRange(projection, 0, master.getLength());
1231 } 1231 }
1232 } 1232 }
1233 } 1233 }
1234 1234
1235 if (projection !is null) { 1235 if (projection !is null) {
1236 Iterator e= fProjectionAnnotationModel.getAnnotationIterator(); 1236 Iterator e= fProjectionAnnotationModel.getAnnotationIterator();
1237 while (e.hasNext()) { 1237 while (e.hasNext()) {
1238 ProjectionAnnotation annotation= (ProjectionAnnotation) e.next(); 1238 ProjectionAnnotation annotation= cast(ProjectionAnnotation) e.next();
1239 if (annotation.isCollapsed()) { 1239 if (annotation.isCollapsed()) {
1240 Position position= fProjectionAnnotationModel.getPosition(annotation); 1240 Position position= fProjectionAnnotationModel.getPosition(annotation);
1241 if (position !is null) { 1241 if (position !is null) {
1242 IRegion[] regions= computeCollapsedRegions(position); 1242 IRegion[] regions= computeCollapsedRegions(position);
1243 if (regions !is null) 1243 if (regions !is null)
1269 * @param column the column to be added 1269 * @param column the column to be added
1270 */ 1270 */
1271 public void addVerticalRulerColumn(IVerticalRulerColumn column) { 1271 public void addVerticalRulerColumn(IVerticalRulerColumn column) {
1272 IVerticalRuler ruler= getVerticalRuler(); 1272 IVerticalRuler ruler= getVerticalRuler();
1273 if (ruler instanceof CompositeRuler) { 1273 if (ruler instanceof CompositeRuler) {
1274 CompositeRuler compositeRuler= (CompositeRuler) ruler; 1274 CompositeRuler compositeRuler= cast(CompositeRuler) ruler;
1275 compositeRuler.addDecorator(99, column); 1275 compositeRuler.addDecorator(99, column);
1276 } 1276 }
1277 } 1277 }
1278 1278
1279 /** 1279 /**
1282 * @param column the column to be removed 1282 * @param column the column to be removed
1283 */ 1283 */
1284 public void removeVerticalRulerColumn(IVerticalRulerColumn column) { 1284 public void removeVerticalRulerColumn(IVerticalRulerColumn column) {
1285 IVerticalRuler ruler= getVerticalRuler(); 1285 IVerticalRuler ruler= getVerticalRuler();
1286 if (ruler instanceof CompositeRuler) { 1286 if (ruler instanceof CompositeRuler) {
1287 CompositeRuler compositeRuler= (CompositeRuler) ruler; 1287 CompositeRuler compositeRuler= cast(CompositeRuler) ruler;
1288 compositeRuler.removeDecorator(column); 1288 compositeRuler.removeDecorator(column);
1289 } 1289 }
1290 } 1290 }
1291 1291
1292 /* 1292 /*
1312 if (moveCursor && fProjectionAnnotationModel !is null && (rangeIndication is null || offset !is rangeIndication.getOffset() || length !is rangeIndication.getLength())) { 1312 if (moveCursor && fProjectionAnnotationModel !is null && (rangeIndication is null || offset !is rangeIndication.getOffset() || length !is rangeIndication.getLength())) {
1313 List expand= new ArrayList(2); 1313 List expand= new ArrayList(2);
1314 // expand the immediate effected collapsed regions 1314 // expand the immediate effected collapsed regions
1315 Iterator iterator= fProjectionAnnotationModel.getAnnotationIterator(); 1315 Iterator iterator= fProjectionAnnotationModel.getAnnotationIterator();
1316 while (iterator.hasNext()) { 1316 while (iterator.hasNext()) {
1317 ProjectionAnnotation annotation= (ProjectionAnnotation)iterator.next(); 1317 ProjectionAnnotation annotation= cast(ProjectionAnnotation)iterator.next();
1318 if (annotation.isCollapsed() && willAutoExpand(fProjectionAnnotationModel.getPosition(annotation), offset, length)) 1318 if (annotation.isCollapsed() && willAutoExpand(fProjectionAnnotationModel.getPosition(annotation), offset, length))
1319 expand.add(annotation); 1319 expand.add(annotation);
1320 } 1320 }
1321 1321
1322 if (!expand.isEmpty()) { 1322 if (!expand.isEmpty()) {
1323 Iterator e= expand.iterator(); 1323 Iterator e= expand.iterator();
1324 while (e.hasNext()) 1324 while (e.hasNext())
1325 fProjectionAnnotationModel.expand((Annotation)e.next()); 1325 fProjectionAnnotationModel.expand(cast(Annotation)e.next());
1326 } 1326 }
1327 } 1327 }
1328 super.setRangeIndication(offset, length, moveCursor); 1328 super.setRangeIndication(offset, length, moveCursor);
1329 } 1329 }
1330 1330
1352 /* 1352 /*
1353 * @see dwtx.jface.text.TextViewer#handleVisibleDocumentAboutToBeChanged(dwtx.jface.text.DocumentEvent) 1353 * @see dwtx.jface.text.TextViewer#handleVisibleDocumentAboutToBeChanged(dwtx.jface.text.DocumentEvent)
1354 */ 1354 */
1355 protected void handleVisibleDocumentChanged(DocumentEvent event) { 1355 protected void handleVisibleDocumentChanged(DocumentEvent event) {
1356 if (fHandleProjectionChanges && event instanceof ProjectionDocumentEvent && isProjectionMode()) { 1356 if (fHandleProjectionChanges && event instanceof ProjectionDocumentEvent && isProjectionMode()) {
1357 ProjectionDocumentEvent e= (ProjectionDocumentEvent) event; 1357 ProjectionDocumentEvent e= cast(ProjectionDocumentEvent) event;
1358 1358
1359 DocumentEvent master= e.getMasterEvent(); 1359 DocumentEvent master= e.getMasterEvent();
1360 if (master !is null) 1360 if (master !is null)
1361 fReplaceVisibleDocumentExecutionTrigger= master.getDocument(); 1361 fReplaceVisibleDocumentExecutionTrigger= master.getDocument();
1362 1362
1404 public IRegion[] getCoveredModelRanges(IRegion modelRange) { 1404 public IRegion[] getCoveredModelRanges(IRegion modelRange) {
1405 if (fInformationMapping is null) 1405 if (fInformationMapping is null)
1406 return new IRegion[] { new Region(modelRange.getOffset(), modelRange.getLength()) }; 1406 return new IRegion[] { new Region(modelRange.getOffset(), modelRange.getLength()) };
1407 1407
1408 if (fInformationMapping instanceof IDocumentInformationMappingExtension) { 1408 if (fInformationMapping instanceof IDocumentInformationMappingExtension) {
1409 IDocumentInformationMappingExtension extension= (IDocumentInformationMappingExtension) fInformationMapping; 1409 IDocumentInformationMappingExtension extension= cast(IDocumentInformationMappingExtension) fInformationMapping;
1410 try { 1410 try {
1411 return extension.getExactCoverage(modelRange); 1411 return extension.getExactCoverage(modelRange);
1412 } catch (BadLocationException x) { 1412 } catch (BadLocationException x) {
1413 } 1413 }
1414 } 1414 }
1710 * @since 3.1 1710 * @since 3.1
1711 */ 1711 */
1712 private Position[] computeOverlappingAnnotationPositions(IRegion modelSelection) { 1712 private Position[] computeOverlappingAnnotationPositions(IRegion modelSelection) {
1713 List positions= new ArrayList(); 1713 List positions= new ArrayList();
1714 for (Iterator e= fProjectionAnnotationModel.getAnnotationIterator(); e.hasNext();) { 1714 for (Iterator e= fProjectionAnnotationModel.getAnnotationIterator(); e.hasNext();) {
1715 ProjectionAnnotation annotation= (ProjectionAnnotation) e.next(); 1715 ProjectionAnnotation annotation= cast(ProjectionAnnotation) e.next();
1716 Position position= fProjectionAnnotationModel.getPosition(annotation); 1716 Position position= fProjectionAnnotationModel.getPosition(annotation);
1717 if (position !is null && position.overlapsWith(modelSelection.getOffset(), modelSelection.getLength()) && modelRange2WidgetRange(position) !is null) 1717 if (position !is null && position.overlapsWith(modelSelection.getOffset(), modelSelection.getLength()) && modelRange2WidgetRange(position) !is null)
1718 positions.add(position); 1718 positions.add(position);
1719 } 1719 }
1720 return (Position[]) positions.toArray(new Position[positions.size()]); 1720 return (Position[]) positions.toArray(new Position[positions.size()]);