comparison dwtx/jface/text/AbstractDocument.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
513 } 513 }
514 514
515 /* 515 /*
516 * @see dwtx.jface.text.IDocument#addPosition(dwtx.jface.text.Position) 516 * @see dwtx.jface.text.IDocument#addPosition(dwtx.jface.text.Position)
517 */ 517 */
518 public void addPosition(Position position) throws BadLocationException { 518 public void addPosition(Position position) {
519 try { 519 try {
520 addPosition(DEFAULT_CATEGORY, position); 520 addPosition(DEFAULT_CATEGORY, position);
521 } catch (BadPositionCategoryException e) { 521 } catch (BadPositionCategoryException e) {
522 } 522 }
523 } 523 }
911 } 911 }
912 912
913 /* 913 /*
914 * @see dwtx.jface.text.IDocument#getChar(int) 914 * @see dwtx.jface.text.IDocument#getChar(int)
915 */ 915 */
916 public char getChar(int pos) throws BadLocationException { 916 public char getChar(int pos) {
917 if ((0 > pos) || (pos >= getLength())) 917 if ((0 > pos) || (pos >= getLength()))
918 throw new BadLocationException(); 918 throw new BadLocationException();
919 return getStore().get(pos); 919 return getStore().get(pos);
920 } 920 }
921 921
922 /* 922 /*
923 * @see dwtx.jface.text.IDocument#getContentType(int) 923 * @see dwtx.jface.text.IDocument#getContentType(int)
924 */ 924 */
925 public String getContentType(int offset) throws BadLocationException { 925 public String getContentType(int offset) {
926 String contentType= null; 926 String contentType= null;
927 try { 927 try {
928 contentType= getContentType(DEFAULT_PARTITIONING, offset, false); 928 contentType= getContentType(DEFAULT_PARTITIONING, offset, false);
929 Assert.isNotNull(contentType); 929 Assert.isNotNull(contentType);
930 } catch (BadPartitioningException e) { 930 } catch (BadPartitioningException e) {
955 } 955 }
956 956
957 /* 957 /*
958 * @see dwtx.jface.text.IDocument#getLineDelimiter(int) 958 * @see dwtx.jface.text.IDocument#getLineDelimiter(int)
959 */ 959 */
960 public String getLineDelimiter(int line) throws BadLocationException { 960 public String getLineDelimiter(int line) {
961 return getTracker().getLineDelimiter(line); 961 return getTracker().getLineDelimiter(line);
962 } 962 }
963 963
964 /* 964 /*
965 * @see dwtx.jface.text.IDocument#getLegalLineDelimiters() 965 * @see dwtx.jface.text.IDocument#getLegalLineDelimiters()
1014 } 1014 }
1015 1015
1016 /* 1016 /*
1017 * @see dwtx.jface.text.IDocument#getLineLength(int) 1017 * @see dwtx.jface.text.IDocument#getLineLength(int)
1018 */ 1018 */
1019 public int getLineLength(int line) throws BadLocationException { 1019 public int getLineLength(int line) {
1020 return getTracker().getLineLength(line); 1020 return getTracker().getLineLength(line);
1021 } 1021 }
1022 1022
1023 /* 1023 /*
1024 * @see dwtx.jface.text.IDocument#getLineOfOffset(int) 1024 * @see dwtx.jface.text.IDocument#getLineOfOffset(int)
1025 */ 1025 */
1026 public int getLineOfOffset(int pos) throws BadLocationException { 1026 public int getLineOfOffset(int pos) {
1027 return getTracker().getLineNumberOfOffset(pos); 1027 return getTracker().getLineNumberOfOffset(pos);
1028 } 1028 }
1029 1029
1030 /* 1030 /*
1031 * @see dwtx.jface.text.IDocument#getLineOffset(int) 1031 * @see dwtx.jface.text.IDocument#getLineOffset(int)
1032 */ 1032 */
1033 public int getLineOffset(int line) throws BadLocationException { 1033 public int getLineOffset(int line) {
1034 return getTracker().getLineOffset(line); 1034 return getTracker().getLineOffset(line);
1035 } 1035 }
1036 1036
1037 /* 1037 /*
1038 * @see dwtx.jface.text.IDocument#getLineInformation(int) 1038 * @see dwtx.jface.text.IDocument#getLineInformation(int)
1039 */ 1039 */
1040 public IRegion getLineInformation(int line) throws BadLocationException { 1040 public IRegion getLineInformation(int line) {
1041 return getTracker().getLineInformation(line); 1041 return getTracker().getLineInformation(line);
1042 } 1042 }
1043 1043
1044 /* 1044 /*
1045 * @see dwtx.jface.text.IDocument#getLineInformationOfOffset(int) 1045 * @see dwtx.jface.text.IDocument#getLineInformationOfOffset(int)
1046 */ 1046 */
1047 public IRegion getLineInformationOfOffset(int offset) throws BadLocationException { 1047 public IRegion getLineInformationOfOffset(int offset) {
1048 return getTracker().getLineInformationOfOffset(offset); 1048 return getTracker().getLineInformationOfOffset(offset);
1049 } 1049 }
1050 1050
1051 /* 1051 /*
1052 * @see dwtx.jface.text.IDocument#getNumberOfLines() 1052 * @see dwtx.jface.text.IDocument#getNumberOfLines()
1056 } 1056 }
1057 1057
1058 /* 1058 /*
1059 * @see dwtx.jface.text.IDocument#getNumberOfLines(int, int) 1059 * @see dwtx.jface.text.IDocument#getNumberOfLines(int, int)
1060 */ 1060 */
1061 public int getNumberOfLines(int offset, int length) throws BadLocationException { 1061 public int getNumberOfLines(int offset, int length) {
1062 return getTracker().getNumberOfLines(offset, length); 1062 return getTracker().getNumberOfLines(offset, length);
1063 } 1063 }
1064 1064
1065 /* 1065 /*
1066 * @see dwtx.jface.text.IDocument#computeNumberOfLines(java.lang.String) 1066 * @see dwtx.jface.text.IDocument#computeNumberOfLines(java.lang.String)
1070 } 1070 }
1071 1071
1072 /* 1072 /*
1073 * @see dwtx.jface.text.IDocument#getPartition(int) 1073 * @see dwtx.jface.text.IDocument#getPartition(int)
1074 */ 1074 */
1075 public ITypedRegion getPartition(int offset) throws BadLocationException { 1075 public ITypedRegion getPartition(int offset) {
1076 ITypedRegion partition= null; 1076 ITypedRegion partition= null;
1077 try { 1077 try {
1078 partition= getPartition(DEFAULT_PARTITIONING, offset, false); 1078 partition= getPartition(DEFAULT_PARTITIONING, offset, false);
1079 Assert.isNotNull(partition); 1079 Assert.isNotNull(partition);
1080 } catch (BadPartitioningException e) { 1080 } catch (BadPartitioningException e) {
1084 } 1084 }
1085 1085
1086 /* 1086 /*
1087 * @see dwtx.jface.text.IDocument#computePartitioning(int, int) 1087 * @see dwtx.jface.text.IDocument#computePartitioning(int, int)
1088 */ 1088 */
1089 public ITypedRegion[] computePartitioning(int offset, int length) throws BadLocationException { 1089 public ITypedRegion[] computePartitioning(int offset, int length) {
1090 ITypedRegion[] partitioning= null; 1090 ITypedRegion[] partitioning= null;
1091 try { 1091 try {
1092 partitioning= computePartitioning(DEFAULT_PARTITIONING, offset, length, false); 1092 partitioning= computePartitioning(DEFAULT_PARTITIONING, offset, length, false);
1093 Assert.isNotNull(partitioning); 1093 Assert.isNotNull(partitioning);
1094 } catch (BadPartitioningException e) { 1094 } catch (BadPartitioningException e) {
1098 } 1098 }
1099 1099
1100 /* 1100 /*
1101 * @see dwtx.jface.text.IDocument#getPositions(java.lang.String) 1101 * @see dwtx.jface.text.IDocument#getPositions(java.lang.String)
1102 */ 1102 */
1103 public Position[] getPositions(String category) throws BadPositionCategoryException { 1103 public Position[] getPositions(String category) {
1104 1104
1105 if (category is null) 1105 if (category is null)
1106 throw new BadPositionCategoryException(); 1106 throw new BadPositionCategoryException();
1107 1107
1108 List c= cast(List) fPositions.get(category); 1108 List c= cast(List) fPositions.get(category);
1142 } 1142 }
1143 1143
1144 /* 1144 /*
1145 * @see dwtx.jface.text.IDocument#get(int, int) 1145 * @see dwtx.jface.text.IDocument#get(int, int)
1146 */ 1146 */
1147 public String get(int pos, int length) throws BadLocationException { 1147 public String get(int pos, int length) {
1148 int myLength= getLength(); 1148 int myLength= getLength();
1149 if ((0 > pos) || (0 > length) || (pos + length > myLength)) 1149 if ((0 > pos) || (0 > length) || (pos + length > myLength))
1150 throw new BadLocationException(); 1150 throw new BadLocationException();
1151 return getStore().get(pos, length); 1151 return getStore().get(pos, length);
1152 } 1152 }
1168 } 1168 }
1169 1169
1170 /* 1170 /*
1171 * @see dwtx.jface.text.IDocument#removePosition(java.lang.String, dwtx.jface.text.Position) 1171 * @see dwtx.jface.text.IDocument#removePosition(java.lang.String, dwtx.jface.text.Position)
1172 */ 1172 */
1173 public void removePosition(String category, Position position) throws BadPositionCategoryException { 1173 public void removePosition(String category, Position position) {
1174 1174
1175 if (position is null) 1175 if (position is null)
1176 return; 1176 return;
1177 1177
1178 if (category is null) 1178 if (category is null)
1239 } 1239 }
1240 1240
1241 /* 1241 /*
1242 * @see dwtx.jface.text.IDocument#removePositionCategory(java.lang.String) 1242 * @see dwtx.jface.text.IDocument#removePositionCategory(java.lang.String)
1243 */ 1243 */
1244 public void removePositionCategory(String category) throws BadPositionCategoryException { 1244 public void removePositionCategory(String category) {
1245 1245
1246 if (category is null) 1246 if (category is null)
1247 return; 1247 return;
1248 1248
1249 if ( !containsPositionCategory(category)) 1249 if ( !containsPositionCategory(category))
1284 1284
1285 /* 1285 /*
1286 * @see dwtx.jface.text.IDocument#replace(int, int, java.lang.String) 1286 * @see dwtx.jface.text.IDocument#replace(int, int, java.lang.String)
1287 * @since 3.1 1287 * @since 3.1
1288 */ 1288 */
1289 public void replace(int pos, int length, String text, long modificationStamp) throws BadLocationException { 1289 public void replace(int pos, int length, String text, long modificationStamp) {
1290 if ((0 > pos) || (0 > length) || (pos + length > getLength())) 1290 if ((0 > pos) || (0 > length) || (pos + length > getLength()))
1291 throw new BadLocationException(); 1291 throw new BadLocationException();
1292 1292
1293 DocumentEvent e= new DocumentEvent(this, pos, length, text); 1293 DocumentEvent e= new DocumentEvent(this, pos, length, text);
1294 fireDocumentAboutToBeChanged(e); 1294 fireDocumentAboutToBeChanged(e);
1306 /** 1306 /**
1307 * {@inheritDoc} 1307 * {@inheritDoc}
1308 * 1308 *
1309 * @since 3.4 1309 * @since 3.4
1310 */ 1310 */
1311 public bool isLineInformationRepairNeeded(int offset, int length, String text) throws BadLocationException { 1311 public bool isLineInformationRepairNeeded(int offset, int length, String text) {
1312 return false; 1312 return false;
1313 } 1313 }
1314 1314
1315 /* 1315 /*
1316 * @see dwtx.jface.text.IDocument#replace(int, int, java.lang.String) 1316 * @see dwtx.jface.text.IDocument#replace(int, int, java.lang.String)
1317 */ 1317 */
1318 public void replace(int pos, int length, String text) throws BadLocationException { 1318 public void replace(int pos, int length, String text) {
1319 if (length is 0 && (text is null || text.length() is 0)) 1319 if (length is 0 && (text is null || text.length() is 0))
1320 replace(pos, length, text, getModificationStamp()); 1320 replace(pos, length, text, getModificationStamp());
1321 else 1321 else
1322 replace(pos, length, text, getNextModificationStamp()); 1322 replace(pos, length, text, getNextModificationStamp());
1323 } 1323 }
1367 } 1367 }
1368 1368
1369 /* 1369 /*
1370 * @see dwtx.jface.text.IDocument#search(int, java.lang.String, bool, bool, bool) 1370 * @see dwtx.jface.text.IDocument#search(int, java.lang.String, bool, bool, bool)
1371 */ 1371 */
1372 public int search(int startPosition, String findString, bool forwardSearch, bool caseSensitive, bool wholeWord) throws BadLocationException { 1372 public int search(int startPosition, String findString, bool forwardSearch, bool caseSensitive, bool wholeWord) {
1373 try { 1373 try {
1374 IRegion region= getFindReplaceDocumentAdapter().find(startPosition, findString, forwardSearch, caseSensitive, wholeWord, false); 1374 IRegion region= getFindReplaceDocumentAdapter().find(startPosition, findString, forwardSearch, caseSensitive, wholeWord, false);
1375 return region is null ? -1 : region.getOffset(); 1375 return region is null ? -1 : region.getOffset();
1376 } catch (IllegalStateException ex) { 1376 } catch (IllegalStateException ex) {
1377 return -1; 1377 return -1;
1573 1573
1574 /* 1574 /*
1575 * @see dwtx.jface.text.IDocumentExtension3#getLegalContentTypes(java.lang.String) 1575 * @see dwtx.jface.text.IDocumentExtension3#getLegalContentTypes(java.lang.String)
1576 * @since 3.0 1576 * @since 3.0
1577 */ 1577 */
1578 public String[] getLegalContentTypes(String partitioning) throws BadPartitioningException { 1578 public String[] getLegalContentTypes(String partitioning) {
1579 IDocumentPartitioner partitioner= getDocumentPartitioner(partitioning); 1579 IDocumentPartitioner partitioner= getDocumentPartitioner(partitioning);
1580 if (partitioner !is null) 1580 if (partitioner !is null)
1581 return partitioner.getLegalContentTypes(); 1581 return partitioner.getLegalContentTypes();
1582 if (DEFAULT_PARTITIONING.equals(partitioning)) 1582 if (DEFAULT_PARTITIONING.equals(partitioning))
1583 return new String[] { DEFAULT_CONTENT_TYPE }; 1583 return new String[] { DEFAULT_CONTENT_TYPE };
1830 * which end after the region if they start at or before the regions end 1830 * which end after the region if they start at or before the regions end
1831 * @return all positions inside the region of the given category 1831 * @return all positions inside the region of the given category
1832 * @throws BadPositionCategoryException if category is undefined in this document 1832 * @throws BadPositionCategoryException if category is undefined in this document
1833 * @since 3.4 1833 * @since 3.4
1834 */ 1834 */
1835 public Position[] getPositions(String category, int offset, int length, bool canStartBefore, bool canEndAfter) throws BadPositionCategoryException { 1835 public Position[] getPositions(String category, int offset, int length, bool canStartBefore, bool canEndAfter) {
1836 if (canStartBefore && canEndAfter || (!canStartBefore && !canEndAfter)) { 1836 if (canStartBefore && canEndAfter || (!canStartBefore && !canEndAfter)) {
1837 List documentPositions; 1837 List documentPositions;
1838 if (canStartBefore && canEndAfter) { 1838 if (canStartBefore && canEndAfter) {
1839 if (offset < getLength() / 2) { 1839 if (offset < getLength() / 2) {
1840 documentPositions= getStartingPositions(category, 0, offset + length); 1840 documentPositions= getStartingPositions(category, 0, offset + length);
1899 * @param length the length of the region 1899 * @param length the length of the region
1900 * @return a list of the positions in the region 1900 * @return a list of the positions in the region
1901 * @throws BadPositionCategoryException if category is undefined in this document 1901 * @throws BadPositionCategoryException if category is undefined in this document
1902 * @since 3.4 1902 * @since 3.4
1903 */ 1903 */
1904 private List getStartingPositions(String category, int offset, int length) throws BadPositionCategoryException { 1904 private List getStartingPositions(String category, int offset, int length) {
1905 List positions= cast(List) fPositions.get(category); 1905 List positions= cast(List) fPositions.get(category);
1906 if (positions is null) 1906 if (positions is null)
1907 throw new BadPositionCategoryException(); 1907 throw new BadPositionCategoryException();
1908 1908
1909 int indexStart= computeIndexInPositionList(positions, offset, true); 1909 int indexStart= computeIndexInPositionList(positions, offset, true);
1921 * @param length the length of the region 1921 * @param length the length of the region
1922 * @return a list of the positions in the region 1922 * @return a list of the positions in the region
1923 * @throws BadPositionCategoryException if category is undefined in this document 1923 * @throws BadPositionCategoryException if category is undefined in this document
1924 * @since 3.4 1924 * @since 3.4
1925 */ 1925 */
1926 private List getEndingPositions(String category, int offset, int length) throws BadPositionCategoryException { 1926 private List getEndingPositions(String category, int offset, int length) {
1927 List positions= cast(List) fEndPositions.get(category); 1927 List positions= cast(List) fEndPositions.get(category);
1928 if (positions is null) 1928 if (positions is null)
1929 throw new BadPositionCategoryException(); 1929 throw new BadPositionCategoryException();
1930 1930
1931 int indexStart= computeIndexInPositionList(positions, offset, false); 1931 int indexStart= computeIndexInPositionList(positions, offset, false);