Mercurial > projects > dwt-addons
comparison dwtx/jface/text/formatter/ContentFormatter.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 |
---|---|
184 * @see Comparable#compareTo(Object) | 184 * @see Comparable#compareTo(Object) |
185 */ | 185 */ |
186 public int compareTo(Object obj) { | 186 public int compareTo(Object obj) { |
187 | 187 |
188 if (obj instanceof PositionReference) { | 188 if (obj instanceof PositionReference) { |
189 PositionReference r= (PositionReference) obj; | 189 PositionReference r= cast(PositionReference) obj; |
190 return getCharacterPosition() - r.getCharacterPosition(); | 190 return getCharacterPosition() - r.getCharacterPosition(); |
191 } | 191 } |
192 | 192 |
193 throw new ClassCastException(); | 193 throw new ClassCastException(); |
194 } | 194 } |
376 Assert.isNotNull(contentType); | 376 Assert.isNotNull(contentType); |
377 | 377 |
378 if (fStrategies is null) | 378 if (fStrategies is null) |
379 return null; | 379 return null; |
380 | 380 |
381 return (IFormattingStrategy) fStrategies.get(contentType); | 381 return cast(IFormattingStrategy) fStrategies.get(contentType); |
382 } | 382 } |
383 | 383 |
384 /* | 384 /* |
385 * @see IContentFormatter#format(IDocument, IRegion) | 385 * @see IContentFormatter#format(IDocument, IRegion) |
386 */ | 386 */ |
688 | 688 |
689 Collections.sort(fOverlappingPositionReferences); | 689 Collections.sort(fOverlappingPositionReferences); |
690 | 690 |
691 int[] positions= new int[fOverlappingPositionReferences.size()]; | 691 int[] positions= new int[fOverlappingPositionReferences.size()]; |
692 for (int i= 0; i < positions.length; i++) { | 692 for (int i= 0; i < positions.length; i++) { |
693 PositionReference r= (PositionReference) fOverlappingPositionReferences.get(i); | 693 PositionReference r= cast(PositionReference) fOverlappingPositionReferences.get(i); |
694 positions[i]= r.getCharacterPosition() - offset; | 694 positions[i]= r.getCharacterPosition() - offset; |
695 } | 695 } |
696 | 696 |
697 return positions; | 697 return positions; |
698 } | 698 } |
704 * @param document the document | 704 * @param document the document |
705 */ | 705 */ |
706 private void removeAffectedPositions(IDocument document) { | 706 private void removeAffectedPositions(IDocument document) { |
707 int size= fOverlappingPositionReferences.size(); | 707 int size= fOverlappingPositionReferences.size(); |
708 for (int i= 0; i < size; i++) { | 708 for (int i= 0; i < size; i++) { |
709 PositionReference r= (PositionReference) fOverlappingPositionReferences.get(i); | 709 PositionReference r= cast(PositionReference) fOverlappingPositionReferences.get(i); |
710 try { | 710 try { |
711 document.removePosition(r.getCategory(), r.getPosition()); | 711 document.removePosition(r.getCategory(), r.getPosition()); |
712 } catch (BadPositionCategoryException x) { | 712 } catch (BadPositionCategoryException x) { |
713 // can not happen | 713 // can not happen |
714 } | 714 } |
731 if (positions.length is 0) | 731 if (positions.length is 0) |
732 return; | 732 return; |
733 | 733 |
734 for (int i= 0; i < positions.length; i++) { | 734 for (int i= 0; i < positions.length; i++) { |
735 | 735 |
736 PositionReference r= (PositionReference) fOverlappingPositionReferences.get(i); | 736 PositionReference r= cast(PositionReference) fOverlappingPositionReferences.get(i); |
737 | 737 |
738 if (r.refersToOffset()) | 738 if (r.refersToOffset()) |
739 r.setOffset(offset + positions[i]); | 739 r.setOffset(offset + positions[i]); |
740 else | 740 else |
741 r.setLength((offset + positions[i]) - r.getOffset()); | 741 r.setLength((offset + positions[i]) - r.getOffset()); |