Mercurial > projects > dwt-addons
annotate dwtx/jface/text/rules/RuleBasedPartitioner.d @ 151:eb21d3dfc767
fix module statement
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 24 Aug 2008 23:55:45 +0200 |
parents | 5cf141e43417 |
children | f70d9508c95c |
rev | line source |
---|---|
129 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2006 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 | |
131 | 14 |
151 | 15 module dwtx.jface.text.rules.RuleBasedPartitioner; |
16 | |
131 | 17 import dwtx.jface.text.rules.FastPartitioner; // packageimport |
18 import dwtx.jface.text.rules.ITokenScanner; // packageimport | |
19 import dwtx.jface.text.rules.Token; // packageimport | |
20 import dwtx.jface.text.rules.RuleBasedScanner; // packageimport | |
21 import dwtx.jface.text.rules.EndOfLineRule; // packageimport | |
22 import dwtx.jface.text.rules.WordRule; // packageimport | |
23 import dwtx.jface.text.rules.WhitespaceRule; // packageimport | |
24 import dwtx.jface.text.rules.WordPatternRule; // packageimport | |
25 import dwtx.jface.text.rules.IPredicateRule; // packageimport | |
26 import dwtx.jface.text.rules.DefaultPartitioner; // packageimport | |
27 import dwtx.jface.text.rules.NumberRule; // packageimport | |
28 import dwtx.jface.text.rules.SingleLineRule; // packageimport | |
29 import dwtx.jface.text.rules.PatternRule; // packageimport | |
30 import dwtx.jface.text.rules.IWordDetector; // packageimport | |
31 import dwtx.jface.text.rules.RuleBasedDamagerRepairer; // packageimport | |
32 import dwtx.jface.text.rules.ICharacterScanner; // packageimport | |
33 import dwtx.jface.text.rules.IRule; // packageimport | |
34 import dwtx.jface.text.rules.DefaultDamagerRepairer; // packageimport | |
35 import dwtx.jface.text.rules.IToken; // packageimport | |
36 import dwtx.jface.text.rules.IPartitionTokenScanner; // packageimport | |
37 import dwtx.jface.text.rules.MultiLineRule; // packageimport | |
38 import dwtx.jface.text.rules.RuleBasedPartitionScanner; // packageimport | |
39 import dwtx.jface.text.rules.BufferedRuleBasedScanner; // packageimport | |
40 import dwtx.jface.text.rules.IWhitespaceDetector; // packageimport | |
41 | |
129 | 42 import dwt.dwthelper.utils; |
43 | |
44 | |
45 import java.util.ArrayList; | |
46 import java.util.List; | |
47 | |
48 import dwtx.core.runtime.Assert; | |
49 import dwtx.jface.text.BadLocationException; | |
50 import dwtx.jface.text.BadPositionCategoryException; | |
51 import dwtx.jface.text.DefaultPositionUpdater; | |
52 import dwtx.jface.text.DocumentEvent; | |
53 import dwtx.jface.text.IDocument; | |
54 import dwtx.jface.text.IDocumentPartitioner; | |
55 import dwtx.jface.text.IDocumentPartitionerExtension; | |
56 import dwtx.jface.text.IDocumentPartitionerExtension2; | |
57 import dwtx.jface.text.IRegion; | |
58 import dwtx.jface.text.ITypedRegion; | |
59 import dwtx.jface.text.Position; | |
60 import dwtx.jface.text.Region; | |
61 import dwtx.jface.text.TextUtilities; | |
62 import dwtx.jface.text.TypedPosition; | |
63 import dwtx.jface.text.TypedRegion; | |
64 | |
65 | |
66 | |
67 /** | |
68 * A standard implementation of a syntax driven document partitioner. | |
69 * It uses a rule based scanner to scan the document and to determine | |
70 * the document's partitioning. The tokens returned by the rules the | |
71 * scanner is configured with are supposed to return the partition type | |
72 * as their data. The partitioner remembers the document's partitions | |
73 * in the document itself rather than maintaining its own data structure. | |
74 * | |
75 * @see IRule | |
76 * @see RuleBasedScanner | |
77 * | |
78 * @deprecated use <code>FastPartitioner</code> instead | |
79 */ | |
80 public class RuleBasedPartitioner : IDocumentPartitioner, IDocumentPartitionerExtension, IDocumentPartitionerExtension2 { | |
81 | |
82 /** | |
83 * The position category this partitioner uses to store the document's partitioning information | |
84 * @deprecated As of 3.0, use <code>getManagingPositionCategories()</code>. | |
85 */ | |
146 | 86 public const static String CONTENT_TYPES_CATEGORY= "__content_types_category"; //$NON-NLS-1$ |
129 | 87 |
88 | |
89 /** The partitioner's scanner */ | |
90 protected RuleBasedScanner fScanner; | |
91 /** The legal content types of this partitioner */ | |
92 protected String[] fLegalContentTypes; | |
93 /** The partitioner's document */ | |
94 protected IDocument fDocument; | |
95 /** The document length before a document change occurred */ | |
96 protected int fPreviousDocumentLength; | |
97 /** The position updater used to for the default updating of partitions */ | |
98 protected DefaultPositionUpdater fPositionUpdater; | |
99 /** The offset at which the first changed partition starts */ | |
100 protected int fStartOffset; | |
101 /** The offset at which the last changed partition ends */ | |
102 protected int fEndOffset; | |
103 /**The offset at which a partition has been deleted */ | |
104 protected int fDeleteOffset; | |
105 /** | |
106 * The position category for managing partitioning information. | |
107 * @since 3.0 | |
108 */ | |
109 private String fPositionCategory; | |
110 | |
111 | |
112 /** | |
113 * Creates a new partitioner that uses the given scanner and may return | |
114 * partitions of the given legal content types. | |
115 * | |
116 * @param scanner the scanner this partitioner is supposed to use | |
117 * @param legalContentTypes the legal content types of this partitioner | |
118 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
119 public this(RuleBasedScanner scanner, String[] legalContentTypes) { |
129 | 120 fScanner= scanner; |
121 fLegalContentTypes= TextUtilities.copy(legalContentTypes); | |
122 fPositionCategory= CONTENT_TYPES_CATEGORY + hashCode(); | |
123 fPositionUpdater= new DefaultPositionUpdater(fPositionCategory); | |
124 } | |
125 | |
126 /* | |
127 * @see dwtx.jface.text.IDocumentPartitionerExtension2#getManagingPositionCategories() | |
128 * @since 3.0 | |
129 */ | |
130 public String[] getManagingPositionCategories() { | |
150 | 131 return [ fPositionCategory ]; |
129 | 132 } |
133 | |
134 /* | |
135 * @see IDocumentPartitioner#connect | |
136 */ | |
137 public void connect(IDocument document) { | |
138 Assert.isNotNull(document); | |
139 Assert.isTrue(!document.containsPositionCategory(fPositionCategory)); | |
140 | |
141 fDocument= document; | |
142 fDocument.addPositionCategory(fPositionCategory); | |
143 | |
144 initialize(); | |
145 } | |
146 | |
147 /** | |
148 * Performs the initial partitioning of the partitioner's document. | |
149 */ | |
150 protected void initialize() { | |
151 | |
152 fScanner.setRange(fDocument, 0, fDocument.getLength()); | |
153 | |
154 try { | |
155 IToken token= fScanner.nextToken(); | |
156 while (!token.isEOF()) { | |
157 | |
158 String contentType= getTokenContentType(token); | |
159 | |
160 if (isSupportedContentType(contentType)) { | |
161 TypedPosition p= new TypedPosition(fScanner.getTokenOffset(), fScanner.getTokenLength(), contentType); | |
162 fDocument.addPosition(fPositionCategory, p); | |
163 } | |
164 | |
165 token= fScanner.nextToken(); | |
166 } | |
167 } catch (BadLocationException x) { | |
168 // cannot happen as offsets come from scanner | |
169 } catch (BadPositionCategoryException x) { | |
170 // cannot happen if document has been connected before | |
171 } | |
172 } | |
173 | |
174 /* | |
175 * @see IDocumentPartitioner#disconnect | |
176 */ | |
177 public void disconnect() { | |
178 | |
179 Assert.isTrue(fDocument.containsPositionCategory(fPositionCategory)); | |
180 | |
181 try { | |
182 fDocument.removePositionCategory(fPositionCategory); | |
183 } catch (BadPositionCategoryException x) { | |
184 // can not happen because of Assert | |
185 } | |
186 } | |
187 | |
188 /* | |
189 * @see IDocumentPartitioner#documentAboutToBeChanged | |
190 */ | |
191 public void documentAboutToBeChanged(DocumentEvent e) { | |
192 | |
193 Assert.isTrue(e.getDocument() is fDocument); | |
194 | |
195 fPreviousDocumentLength= e.getDocument().getLength(); | |
196 fStartOffset= -1; | |
197 fEndOffset= -1; | |
198 fDeleteOffset= -1; | |
199 } | |
200 | |
201 /* | |
202 * @see IDocumentPartitioner#documentChanged | |
203 */ | |
204 public bool documentChanged(DocumentEvent e) { | |
205 IRegion region= documentChanged2(e); | |
206 return (region !is null); | |
207 } | |
208 | |
209 /** | |
210 * Helper method for tracking the minimal region containing all partition changes. | |
211 * If <code>offset</code> is smaller than the remembered offset, <code>offset</code> | |
212 * will from now on be remembered. If <code>offset + length</code> is greater than | |
213 * the remembered end offset, it will be remembered from now on. | |
214 * | |
215 * @param offset the offset | |
216 * @param length the length | |
217 */ | |
218 private void rememberRegion(int offset, int length) { | |
219 // remember start offset | |
220 if (fStartOffset is -1) | |
221 fStartOffset= offset; | |
222 else if (offset < fStartOffset) | |
223 fStartOffset= offset; | |
224 | |
225 // remember end offset | |
226 int endOffset= offset + length; | |
227 if (fEndOffset is -1) | |
228 fEndOffset= endOffset; | |
229 else if (endOffset > fEndOffset) | |
230 fEndOffset= endOffset; | |
231 } | |
232 | |
233 /** | |
234 * Remembers the given offset as the deletion offset. | |
235 * | |
236 * @param offset the offset | |
237 */ | |
238 private void rememberDeletedOffset(int offset) { | |
239 fDeleteOffset= offset; | |
240 } | |
241 | |
242 /** | |
243 * Creates the minimal region containing all partition changes using the | |
244 * remembered offset, end offset, and deletion offset. | |
245 * @return the minimal region containing all the partition changes | |
246 */ | |
247 private IRegion createRegion() { | |
248 if (fDeleteOffset is -1) { | |
249 if (fStartOffset is -1 || fEndOffset is -1) | |
250 return null; | |
251 return new Region(fStartOffset, fEndOffset - fStartOffset); | |
252 } else if (fStartOffset is -1 || fEndOffset is -1) { | |
253 return new Region(fDeleteOffset, 0); | |
254 } else { | |
255 int offset= Math.min(fDeleteOffset, fStartOffset); | |
256 int endOffset= Math.max(fDeleteOffset, fEndOffset); | |
257 return new Region(offset, endOffset - offset); | |
258 } | |
259 } | |
260 | |
261 /* | |
262 * @see IDocumentPartitionerExtension#documentChanged2(DocumentEvent) | |
263 * @since 2.0 | |
264 */ | |
265 public IRegion documentChanged2(DocumentEvent e) { | |
266 | |
267 try { | |
268 | |
269 IDocument d= e.getDocument(); | |
270 Position[] category= d.getPositions(fPositionCategory); | |
271 int first= 0; | |
272 int reparseStart= 0; | |
273 int originalSize= category.length; | |
274 | |
275 if (originalSize > 0) { | |
276 | |
277 /* | |
278 * determine character position at which the scanner starts: | |
279 * first position behind the last non-default partition the actual position is not involved with | |
280 */ | |
281 | |
282 first= d.computeIndexInCategory(fPositionCategory, e.getOffset()); | |
283 | |
284 Position p= null; | |
285 do { | |
286 --first; | |
287 if (first < 0) | |
288 break; | |
289 | |
290 p= category[first]; | |
291 | |
292 } while (p.overlapsWith(e.getOffset(), e.getLength()) || | |
293 (e.getOffset() is fPreviousDocumentLength && | |
294 (p.getOffset() + p.getLength() is fPreviousDocumentLength))); | |
295 | |
296 fPositionUpdater.update(e); | |
297 for (int i= 0; i < category.length; i++) { | |
298 p= category[i]; | |
299 if (p.isDeleted) { | |
300 rememberDeletedOffset(e.getOffset()); | |
301 break; | |
302 } | |
303 } | |
304 category= d.getPositions(fPositionCategory); | |
305 | |
306 if (first >= 0) { | |
307 p= category[first]; | |
308 reparseStart= p.getOffset() + p.getLength(); | |
309 } | |
310 | |
311 ++first; | |
312 } | |
313 | |
314 fScanner.setRange(d, reparseStart, d.getLength() - reparseStart); | |
315 | |
316 int lastScannedPosition= reparseStart; | |
317 IToken token= fScanner.nextToken(); | |
318 | |
319 while (!token.isEOF()) { | |
320 | |
321 | |
322 String contentType= getTokenContentType(token); | |
323 | |
324 if (!isSupportedContentType(contentType)) { | |
325 token= fScanner.nextToken(); | |
326 continue; | |
327 } | |
328 | |
329 int start= fScanner.getTokenOffset(); | |
330 int length= fScanner.getTokenLength(); | |
331 | |
332 lastScannedPosition= start + length - 1; | |
333 | |
334 // remove all affected positions | |
335 while (first < category.length) { | |
134 | 336 TypedPosition p= cast(TypedPosition) category[first]; |
129 | 337 if (lastScannedPosition >= p.offset + p.length || |
338 (p.overlapsWith(start, length) && | |
339 (!d.containsPosition(fPositionCategory, start, length) || | |
340 !contentType.equals(p.getType())))) { | |
341 | |
342 rememberRegion(p.offset, p.length); | |
343 d.removePosition(fPositionCategory, p); | |
344 ++ first; | |
345 | |
346 } else | |
347 break; | |
348 } | |
349 | |
350 // if position already exists we are done | |
351 if (d.containsPosition(fPositionCategory, start, length)) | |
352 return createRegion(); | |
353 | |
354 // insert the new type position | |
355 try { | |
356 d.addPosition(fPositionCategory, new TypedPosition(start, length, contentType)); | |
357 rememberRegion(start, length); | |
358 } catch (BadPositionCategoryException x) { | |
359 } catch (BadLocationException x) { | |
360 } | |
361 | |
362 token= fScanner.nextToken(); | |
363 } | |
364 | |
365 | |
366 // remove all positions behind lastScannedPosition since there aren't any further types | |
367 if (lastScannedPosition !is reparseStart) { | |
368 // if this condition is not met, nothing has been scanned because of a delete | |
369 ++ lastScannedPosition; | |
370 } | |
371 first= d.computeIndexInCategory(fPositionCategory, lastScannedPosition); | |
372 | |
373 TypedPosition p; | |
374 while (first < category.length) { | |
134 | 375 p= cast(TypedPosition) category[first++]; |
129 | 376 d.removePosition(fPositionCategory, p); |
377 rememberRegion(p.offset, p.length); | |
378 } | |
379 | |
380 } catch (BadPositionCategoryException x) { | |
381 // should never happen on connected documents | |
382 } catch (BadLocationException x) { | |
383 } | |
384 | |
385 return createRegion(); | |
386 } | |
387 | |
388 | |
389 /** | |
390 * Returns the position in the partitoner's position category which is | |
391 * close to the given offset. This is, the position has either an offset which | |
392 * is the same as the given offset or an offset which is smaller than the given | |
393 * offset. This method profits from the knowledge that a partitioning is | |
394 * a ordered set of disjoint position. | |
395 * | |
396 * @param offset the offset for which to search the closest position | |
397 * @return the closest position in the partitioner's category | |
398 */ | |
399 protected TypedPosition findClosestPosition(int offset) { | |
400 | |
401 try { | |
402 | |
403 int index= fDocument.computeIndexInCategory(fPositionCategory, offset); | |
404 Position[] category= fDocument.getPositions(fPositionCategory); | |
405 | |
406 if (category.length is 0) | |
407 return null; | |
408 | |
409 if (index < category.length) { | |
410 if (offset is category[index].offset) | |
134 | 411 return cast(TypedPosition) category[index]; |
129 | 412 } |
413 | |
414 if (index > 0) | |
415 index--; | |
416 | |
134 | 417 return cast(TypedPosition) category[index]; |
129 | 418 |
419 } catch (BadPositionCategoryException x) { | |
420 } catch (BadLocationException x) { | |
421 } | |
422 | |
423 return null; | |
424 } | |
425 | |
426 | |
427 /* | |
428 * @see IDocumentPartitioner#getContentType | |
429 */ | |
430 public String getContentType(int offset) { | |
431 | |
432 TypedPosition p= findClosestPosition(offset); | |
433 if (p !is null && p.includes(offset)) | |
434 return p.getType(); | |
435 | |
436 return IDocument.DEFAULT_CONTENT_TYPE; | |
437 } | |
438 | |
439 /* | |
440 * @see IDocumentPartitioner#getPartition | |
441 */ | |
442 public ITypedRegion getPartition(int offset) { | |
443 | |
444 try { | |
445 | |
446 Position[] category = fDocument.getPositions(fPositionCategory); | |
447 | |
448 if (category is null || category.length is 0) | |
449 return new TypedRegion(0, fDocument.getLength(), IDocument.DEFAULT_CONTENT_TYPE); | |
450 | |
451 int index= fDocument.computeIndexInCategory(fPositionCategory, offset); | |
452 | |
453 if (index < category.length) { | |
454 | |
134 | 455 TypedPosition next= cast(TypedPosition) category[index]; |
129 | 456 |
457 if (offset is next.offset) | |
458 return new TypedRegion(next.getOffset(), next.getLength(), next.getType()); | |
459 | |
460 if (index is 0) | |
461 return new TypedRegion(0, next.offset, IDocument.DEFAULT_CONTENT_TYPE); | |
462 | |
134 | 463 TypedPosition previous= cast(TypedPosition) category[index - 1]; |
129 | 464 if (previous.includes(offset)) |
465 return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType()); | |
466 | |
467 int endOffset= previous.getOffset() + previous.getLength(); | |
468 return new TypedRegion(endOffset, next.getOffset() - endOffset, IDocument.DEFAULT_CONTENT_TYPE); | |
469 } | |
470 | |
134 | 471 TypedPosition previous= cast(TypedPosition) category[category.length - 1]; |
129 | 472 if (previous.includes(offset)) |
473 return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType()); | |
474 | |
475 int endOffset= previous.getOffset() + previous.getLength(); | |
476 return new TypedRegion(endOffset, fDocument.getLength() - endOffset, IDocument.DEFAULT_CONTENT_TYPE); | |
477 | |
478 } catch (BadPositionCategoryException x) { | |
479 } catch (BadLocationException x) { | |
480 } | |
481 | |
482 return new TypedRegion(0, fDocument.getLength(), IDocument.DEFAULT_CONTENT_TYPE); | |
483 } | |
484 | |
485 /* | |
486 * @see IDocumentPartitioner#computePartitioning | |
487 */ | |
488 public ITypedRegion[] computePartitioning(int offset, int length) { | |
489 return computePartitioning(offset, length, false); | |
490 } | |
491 | |
492 /* | |
493 * @see IDocumentPartitioner#getLegalContentTypes | |
494 */ | |
495 public String[] getLegalContentTypes() { | |
496 return TextUtilities.copy(fLegalContentTypes); | |
497 } | |
498 | |
499 /** | |
500 * Returns whether the given type is one of the legal content types. | |
501 * | |
502 * @param contentType the content type to check | |
503 * @return <code>true</code> if the content type is a legal content type | |
504 */ | |
505 protected bool isSupportedContentType(String contentType) { | |
506 if (contentType !is null) { | |
507 for (int i= 0; i < fLegalContentTypes.length; i++) { | |
508 if (fLegalContentTypes[i].equals(contentType)) | |
509 return true; | |
510 } | |
511 } | |
512 | |
513 return false; | |
514 } | |
515 | |
516 /** | |
517 * Returns a content type encoded in the given token. If the token's | |
518 * data is not <code>null</code> and a string it is assumed that | |
519 * it is the encoded content type. | |
520 * | |
521 * @param token the token whose content type is to be determined | |
522 * @return the token's content type | |
523 */ | |
524 protected String getTokenContentType(IToken token) { | |
525 Object data= token.getData(); | |
138 | 526 if ( cast(String)data ) |
134 | 527 return cast(String) data; |
129 | 528 return null; |
529 } | |
530 | |
531 /* zero-length partition support */ | |
532 | |
533 /* | |
534 * @see dwtx.jface.text.IDocumentPartitionerExtension2#getContentType(int) | |
535 * @since 3.0 | |
536 */ | |
537 public String getContentType(int offset, bool preferOpenPartitions) { | |
538 return getPartition(offset, preferOpenPartitions).getType(); | |
539 } | |
540 | |
541 /* | |
542 * @see dwtx.jface.text.IDocumentPartitionerExtension2#getPartition(int) | |
543 * @since 3.0 | |
544 */ | |
545 public ITypedRegion getPartition(int offset, bool preferOpenPartitions) { | |
546 ITypedRegion region= getPartition(offset); | |
547 if (preferOpenPartitions) { | |
548 if (region.getOffset() is offset && !region.getType().equals(IDocument.DEFAULT_CONTENT_TYPE)) { | |
549 if (offset > 0) { | |
550 region= getPartition(offset - 1); | |
551 if (region.getType().equals(IDocument.DEFAULT_CONTENT_TYPE)) | |
552 return region; | |
553 } | |
554 return new TypedRegion(offset, 0, IDocument.DEFAULT_CONTENT_TYPE); | |
555 } | |
556 } | |
557 return region; | |
558 } | |
559 | |
560 /* | |
561 * @see dwtx.jface.text.IDocumentPartitionerExtension2#computePartitioning(int, int) | |
562 * @since 3.0 | |
563 */ | |
564 public ITypedRegion[] computePartitioning(int offset, int length, bool includeZeroLengthPartitions) { | |
565 List list= new ArrayList(); | |
566 | |
567 try { | |
568 | |
569 int endOffset= offset + length; | |
570 | |
571 Position[] category= fDocument.getPositions(fPositionCategory); | |
572 | |
573 TypedPosition previous= null, current= null; | |
574 int start, end, gapOffset; | |
575 Position gap= null; | |
576 | |
577 for (int i= 0; i < category.length; i++) { | |
578 | |
134 | 579 current= cast(TypedPosition) category[i]; |
129 | 580 |
581 gapOffset= (previous !is null) ? previous.getOffset() + previous.getLength() : 0; | |
582 gap= new Position(gapOffset, current.getOffset() - gapOffset); | |
583 if ((includeZeroLengthPartitions || gap.getLength() > 0) && gap.overlapsWith(offset, length)) { | |
584 start= Math.max(offset, gapOffset); | |
585 end= Math.min(endOffset, gap.getOffset() + gap.getLength()); | |
586 list.add(new TypedRegion(start, end - start, IDocument.DEFAULT_CONTENT_TYPE)); | |
587 } | |
588 | |
589 if (current.overlapsWith(offset, length)) { | |
590 start= Math.max(offset, current.getOffset()); | |
591 end= Math.min(endOffset, current.getOffset() + current.getLength()); | |
592 list.add(new TypedRegion(start, end - start, current.getType())); | |
593 } | |
594 | |
595 previous= current; | |
596 } | |
597 | |
598 if (previous !is null) { | |
599 gapOffset= previous.getOffset() + previous.getLength(); | |
600 gap= new Position(gapOffset, fDocument.getLength() - gapOffset); | |
601 if ((includeZeroLengthPartitions || gap.getLength() > 0) && ((includeZeroLengthPartitions && offset + length is gapOffset && gap.length is 0) || gap.overlapsWith(offset, length))) { | |
602 start= Math.max(offset, gapOffset); | |
603 end= Math.min(endOffset, fDocument.getLength()); | |
604 list.add(new TypedRegion(start, end - start, IDocument.DEFAULT_CONTENT_TYPE)); | |
605 } | |
606 } | |
607 | |
608 if (list.isEmpty()) | |
609 list.add(new TypedRegion(offset, length, IDocument.DEFAULT_CONTENT_TYPE)); | |
610 | |
611 } catch (BadPositionCategoryException x) { | |
612 } | |
613 | |
614 TypedRegion[] result= new TypedRegion[list.size()]; | |
615 list.toArray(result); | |
616 return result; | |
617 } | |
618 } |