comparison dwtx/jface/text/source/DefaultCharacterPairMatcher.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 7d818bd32d63
children 75302ef3f92f
comparison
equal deleted inserted replaced
135:65801ad2b265 136:6dcb0baaa031
150 } 150 }
151 151
152 /* 152 /*
153 * Performs the actual work of matching for #match(IDocument, int). 153 * Performs the actual work of matching for #match(IDocument, int).
154 */ 154 */
155 private IRegion performMatch(IDocument doc, int caretOffset) throws BadLocationException { 155 private IRegion performMatch(IDocument doc, int caretOffset) {
156 final int charOffset= caretOffset - 1; 156 final int charOffset= caretOffset - 1;
157 final char prevChar= doc.getChar(Math.max(charOffset, 0)); 157 final char prevChar= doc.getChar(Math.max(charOffset, 0));
158 if (!fPairs.contains(prevChar)) return null; 158 if (!fPairs.contains(prevChar)) return null;
159 final bool isForward= fPairs.isStartCharacter(prevChar); 159 final bool isForward= fPairs.isStartCharacter(prevChar);
160 fAnchor= isForward ? ICharacterPairMatcher.LEFT : ICharacterPairMatcher.RIGHT; 160 fAnchor= isForward ? ICharacterPairMatcher.LEFT : ICharacterPairMatcher.RIGHT;
182 * @param boundary a boundary at which the search should stop 182 * @param boundary a boundary at which the search should stop
183 * @param startPos the start offset 183 * @param startPos the start offset
184 * @return the index of the end character if it was found, otherwise -1 184 * @return the index of the end character if it was found, otherwise -1
185 * @throws BadLocationException 185 * @throws BadLocationException
186 */ 186 */
187 private int findMatchingPeer(DocumentPartitionAccessor doc, char start, char end, bool searchForward, int boundary, int startPos) throws BadLocationException { 187 private int findMatchingPeer(DocumentPartitionAccessor doc, char start, char end, bool searchForward, int boundary, int startPos) {
188 int pos= startPos; 188 int pos= startPos;
189 while (pos !is boundary) { 189 while (pos !is boundary) {
190 final char c= doc.getChar(pos); 190 final char c= doc.getChar(pos);
191 if (doc.isMatch(pos, end)) { 191 if (doc.isMatch(pos, end)) {
192 return pos; 192 return pos;
244 * 244 *
245 * @param pos an offset within this document 245 * @param pos an offset within this document
246 * @return the character at the offset 246 * @return the character at the offset
247 * @throws BadLocationException 247 * @throws BadLocationException
248 */ 248 */
249 public char getChar(int pos) throws BadLocationException { 249 public char getChar(int pos) {
250 return fDocument.getChar(pos); 250 return fDocument.getChar(pos);
251 } 251 }
252 252
253 /** 253 /**
254 * Returns true if the character at the specified position is a 254 * Returns true if the character at the specified position is a
259 * @param pos an offset within this document 259 * @param pos an offset within this document
260 * @param end the end character to match against 260 * @param end the end character to match against
261 * @return true exactly if the position represents a valid match 261 * @return true exactly if the position represents a valid match
262 * @throws BadLocationException 262 * @throws BadLocationException
263 */ 263 */
264 public bool isMatch(int pos, char end) throws BadLocationException { 264 public bool isMatch(int pos, char end) {
265 return getChar(pos) is end && inPartition(pos); 265 return getChar(pos) is end && inPartition(pos);
266 } 266 }
267 267
268 /** 268 /**
269 * Returns true if the specified offset is within the partition 269 * Returns true if the specified offset is within the partition