Mercurial > projects > dwt-addons
annotate dwtx/jface/text/presentation/PresentationReconciler.d @ 159:7926b636c282
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 27 Aug 2008 01:57:58 +0200 |
parents | f70d9508c95c |
children |
rev | line source |
---|---|
129 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2008 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.presentation.PresentationReconciler; |
16 | |
131 | 17 import dwtx.jface.text.presentation.IPresentationDamager; // packageimport |
18 import dwtx.jface.text.presentation.IPresentationReconciler; // packageimport | |
19 import dwtx.jface.text.presentation.IPresentationRepairer; // packageimport | |
20 import dwtx.jface.text.presentation.IPresentationReconcilerExtension; // packageimport | |
21 | |
129 | 22 import dwt.dwthelper.utils; |
23 | |
153
f70d9508c95c
Fix java Collection imports
Frank Benoit <benoit@tionex.de>
parents:
151
diff
changeset
|
24 import dwtx.dwtxhelper.Collection; |
f70d9508c95c
Fix java Collection imports
Frank Benoit <benoit@tionex.de>
parents:
151
diff
changeset
|
25 |
f70d9508c95c
Fix java Collection imports
Frank Benoit <benoit@tionex.de>
parents:
151
diff
changeset
|
26 |
129 | 27 |
28 import dwt.custom.StyleRange; | |
29 import dwtx.core.runtime.Assert; | |
30 import dwtx.jface.text.BadLocationException; | |
31 import dwtx.jface.text.BadPositionCategoryException; | |
32 import dwtx.jface.text.DefaultPositionUpdater; | |
33 import dwtx.jface.text.DocumentEvent; | |
34 import dwtx.jface.text.DocumentPartitioningChangedEvent; | |
35 import dwtx.jface.text.IDocument; | |
36 import dwtx.jface.text.IDocumentExtension3; | |
37 import dwtx.jface.text.IDocumentListener; | |
38 import dwtx.jface.text.IDocumentPartitioningListener; | |
39 import dwtx.jface.text.IDocumentPartitioningListenerExtension; | |
40 import dwtx.jface.text.IDocumentPartitioningListenerExtension2; | |
41 import dwtx.jface.text.IPositionUpdater; | |
42 import dwtx.jface.text.IRegion; | |
43 import dwtx.jface.text.ITextInputListener; | |
44 import dwtx.jface.text.ITextListener; | |
45 import dwtx.jface.text.ITextViewer; | |
46 import dwtx.jface.text.ITextViewerExtension5; | |
47 import dwtx.jface.text.ITypedRegion; | |
48 import dwtx.jface.text.Region; | |
49 import dwtx.jface.text.TextEvent; | |
50 import dwtx.jface.text.TextPresentation; | |
51 import dwtx.jface.text.TextUtilities; | |
52 import dwtx.jface.text.TypedPosition; | |
53 | |
54 | |
55 | |
56 /** | |
57 * Standard implementation of <code>IPresentationReconciler</code>. This | |
58 * implementation assumes that the tasks performed by its presentation damagers | |
59 * and repairers are lightweight and of low cost. This presentation reconciler | |
60 * runs in the UI thread and always repairs the complete damage caused by a | |
61 * document change rather than just the portion overlapping with the viewer's | |
62 * viewport. | |
63 * <p> | |
64 * Usually, clients instantiate this class and configure it before using it. | |
65 * </p> | |
66 */ | |
67 public class PresentationReconciler : IPresentationReconciler, IPresentationReconcilerExtension { | |
68 | |
69 /** Prefix of the name of the position category for tracking damage regions. */ | |
159 | 70 protected const static String TRACKED_PARTITION= "__reconciler_tracked_partition"; //$NON-NLS-1$ |
129 | 71 |
72 | |
73 /** | |
74 * Internal listener class. | |
75 */ | |
76 class InternalListener : | |
77 ITextInputListener, IDocumentListener, ITextListener, | |
78 IDocumentPartitioningListener, IDocumentPartitioningListenerExtension, IDocumentPartitioningListenerExtension2 { | |
79 | |
80 /** Set to <code>true</code> if between a document about to be changed and a changed event. */ | |
81 private bool fDocumentChanging= false; | |
82 /** | |
83 * The cached redraw state of the text viewer. | |
84 * @since 3.0 | |
85 */ | |
86 private bool fCachedRedrawState= true; | |
87 | |
88 /* | |
89 * @see ITextInputListener#inputDocumentAboutToBeChanged(IDocument, IDocument) | |
90 */ | |
91 public void inputDocumentAboutToBeChanged(IDocument oldDocument, IDocument newDocument) { | |
92 if (oldDocument !is null) { | |
93 try { | |
94 | |
95 fViewer.removeTextListener(this); | |
96 oldDocument.removeDocumentListener(this); | |
97 oldDocument.removeDocumentPartitioningListener(this); | |
98 | |
99 oldDocument.removePositionUpdater(fPositionUpdater); | |
100 oldDocument.removePositionCategory(fPositionCategory); | |
101 | |
102 } catch (BadPositionCategoryException x) { | |
103 // should not happened for former input documents; | |
104 } | |
105 } | |
106 } | |
107 | |
108 /* | |
109 * @see ITextInputListener#inputDocumenChanged(IDocument, IDocument) | |
110 */ | |
111 public void inputDocumentChanged(IDocument oldDocument, IDocument newDocument) { | |
112 | |
113 fDocumentChanging= false; | |
114 fCachedRedrawState= true; | |
115 | |
116 if (newDocument !is null) { | |
117 | |
118 newDocument.addPositionCategory(fPositionCategory); | |
119 newDocument.addPositionUpdater(fPositionUpdater); | |
120 | |
121 newDocument.addDocumentPartitioningListener(this); | |
122 newDocument.addDocumentListener(this); | |
123 fViewer.addTextListener(this); | |
124 | |
125 setDocumentToDamagers(newDocument); | |
126 setDocumentToRepairers(newDocument); | |
127 processDamage(new Region(0, newDocument.getLength()), newDocument); | |
128 } | |
129 } | |
130 | |
131 /* | |
132 * @see IDocumentPartitioningListener#documentPartitioningChanged(IDocument) | |
133 */ | |
134 public void documentPartitioningChanged(IDocument document) { | |
135 if (!fDocumentChanging && fCachedRedrawState) | |
136 processDamage(new Region(0, document.getLength()), document); | |
137 else | |
138 fDocumentPartitioningChanged= true; | |
139 } | |
140 | |
141 /* | |
142 * @see IDocumentPartitioningListenerExtension#documentPartitioningChanged(IDocument, IRegion) | |
143 * @since 2.0 | |
144 */ | |
145 public void documentPartitioningChanged(IDocument document, IRegion changedRegion) { | |
146 if (!fDocumentChanging && fCachedRedrawState) { | |
147 processDamage(new Region(changedRegion.getOffset(), changedRegion.getLength()), document); | |
148 } else { | |
149 fDocumentPartitioningChanged= true; | |
150 fChangedDocumentPartitions= changedRegion; | |
151 } | |
152 } | |
153 | |
154 /* | |
155 * @see dwtx.jface.text.IDocumentPartitioningListenerExtension2#documentPartitioningChanged(dwtx.jface.text.DocumentPartitioningChangedEvent) | |
156 * @since 3.0 | |
157 */ | |
158 public void documentPartitioningChanged(DocumentPartitioningChangedEvent event) { | |
159 IRegion changedRegion= event.getChangedRegion(getDocumentPartitioning()); | |
160 if (changedRegion !is null) | |
161 documentPartitioningChanged(event.getDocument(), changedRegion); | |
162 } | |
163 | |
164 /* | |
165 * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent) | |
166 */ | |
167 public void documentAboutToBeChanged(DocumentEvent e) { | |
168 | |
169 fDocumentChanging= true; | |
170 if (fCachedRedrawState) { | |
171 try { | |
172 int offset= e.getOffset() + e.getLength(); | |
173 ITypedRegion region= getPartition(e.getDocument(), offset); | |
174 fRememberedPosition= new TypedPosition(region); | |
175 e.getDocument().addPosition(fPositionCategory, fRememberedPosition); | |
176 } catch (BadLocationException x) { | |
177 // can not happen | |
178 } catch (BadPositionCategoryException x) { | |
179 // should not happen on input elements | |
180 } | |
181 } | |
182 } | |
183 | |
184 /* | |
185 * @see IDocumentListener#documentChanged(DocumentEvent) | |
186 */ | |
187 public void documentChanged(DocumentEvent e) { | |
188 if (fCachedRedrawState) { | |
189 try { | |
190 e.getDocument().removePosition(fPositionCategory, fRememberedPosition); | |
191 } catch (BadPositionCategoryException x) { | |
192 // can not happen on input documents | |
193 } | |
194 } | |
195 fDocumentChanging= false; | |
196 } | |
197 | |
198 /* | |
199 * @see ITextListener#textChanged(TextEvent) | |
200 */ | |
201 public void textChanged(TextEvent e) { | |
202 | |
203 fCachedRedrawState= e.getViewerRedrawState(); | |
204 if (!fCachedRedrawState) | |
205 return; | |
206 | |
207 IRegion damage= null; | |
208 IDocument document= null; | |
209 | |
210 if (e.getDocumentEvent() is null) { | |
211 document= fViewer.getDocument(); | |
212 if (document !is null) { | |
213 if (e.getOffset() is 0 && e.getLength() is 0 && e.getText() is null) { | |
214 // redraw state change, damage the whole document | |
215 damage= new Region(0, document.getLength()); | |
216 } else { | |
217 IRegion region= widgetRegion2ModelRegion(e); | |
218 try { | |
219 String text= document.get(region.getOffset(), region.getLength()); | |
220 DocumentEvent de= new DocumentEvent(document, region.getOffset(), region.getLength(), text); | |
221 damage= getDamage(de, false); | |
222 } catch (BadLocationException x) { | |
223 } | |
224 } | |
225 } | |
226 } else { | |
227 DocumentEvent de= e.getDocumentEvent(); | |
228 document= de.getDocument(); | |
229 damage= getDamage(de, true); | |
230 } | |
231 | |
232 if (damage !is null && document !is null) | |
233 processDamage(damage, document); | |
234 | |
235 fDocumentPartitioningChanged= false; | |
236 fChangedDocumentPartitions= null; | |
237 } | |
238 | |
239 /** | |
240 * Translates the given text event into the corresponding range of the viewer's document. | |
241 * | |
242 * @param e the text event | |
243 * @return the widget region corresponding the region of the given event | |
244 * @since 2.1 | |
245 */ | |
246 protected IRegion widgetRegion2ModelRegion(TextEvent e) { | |
247 | |
248 String text= e.getText(); | |
249 int length= text is null ? 0 : text.length(); | |
250 | |
138 | 251 if ( cast(ITextViewerExtension5)fViewer ) { |
134 | 252 ITextViewerExtension5 extension= cast(ITextViewerExtension5) fViewer; |
129 | 253 return extension.widgetRange2ModelRange(new Region(e.getOffset(), length)); |
254 } | |
255 | |
256 IRegion visible= fViewer.getVisibleRegion(); | |
257 IRegion region= new Region(e.getOffset() + visible.getOffset(), length); | |
258 return region; | |
259 } | |
260 } | |
261 | |
262 /** The map of presentation damagers. */ | |
263 private Map fDamagers; | |
264 /** The map of presentation repairers. */ | |
265 private Map fRepairers; | |
266 /** The target viewer. */ | |
267 private ITextViewer fViewer; | |
268 /** The internal listener. */ | |
159 | 269 private InternalListener fInternalListener; |
129 | 270 /** The name of the position category to track damage regions. */ |
271 private String fPositionCategory; | |
272 /** The position updated for the damage regions' position category. */ | |
273 private IPositionUpdater fPositionUpdater; | |
274 /** The positions representing the damage regions. */ | |
275 private TypedPosition fRememberedPosition; | |
276 /** Flag indicating the receipt of a partitioning changed notification. */ | |
277 private bool fDocumentPartitioningChanged= false; | |
278 /** The range covering the changed partitioning. */ | |
279 private IRegion fChangedDocumentPartitions= null; | |
280 /** | |
281 * The partitioning used by this presentation reconciler. | |
282 * @since 3.0 | |
283 */ | |
284 private String fPartitioning; | |
285 | |
286 /** | |
287 * Creates a new presentation reconciler. There are no damagers or repairers | |
288 * registered with this reconciler by default. The default partitioning | |
289 * <code>IDocumentExtension3.DEFAULT_PARTITIONING</code> is used. | |
290 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
291 public this() { |
159 | 292 fInternalListener= new InternalListener(); |
293 // super(); | |
129 | 294 fPartitioning= IDocumentExtension3.DEFAULT_PARTITIONING; |
159 | 295 fPositionCategory= TRACKED_PARTITION ~ Integer.toString(toHash()); |
129 | 296 fPositionUpdater= new DefaultPositionUpdater(fPositionCategory); |
297 } | |
298 | |
299 /** | |
300 * Sets the document partitioning for this presentation reconciler. | |
301 * | |
302 * @param partitioning the document partitioning for this presentation reconciler. | |
303 * @since 3.0 | |
304 */ | |
305 public void setDocumentPartitioning(String partitioning) { | |
306 Assert.isNotNull(partitioning); | |
307 fPartitioning= partitioning; | |
308 } | |
309 | |
310 /* | |
311 * @see dwtx.jface.text.presentation.IPresentationReconcilerExtension#geDocumenttPartitioning() | |
312 * @since 3.0 | |
313 */ | |
314 public String getDocumentPartitioning() { | |
315 return fPartitioning; | |
316 } | |
317 | |
318 /** | |
319 * Registers the given presentation damager for a particular content type. | |
320 * If there is already a damager registered for this type, the old damager | |
321 * is removed first. | |
322 * | |
323 * @param damager the presentation damager to register, or <code>null</code> to remove an existing one | |
324 * @param contentType the content type under which to register | |
325 */ | |
326 public void setDamager(IPresentationDamager damager, String contentType) { | |
327 | |
328 Assert.isNotNull(contentType); | |
329 | |
330 if (fDamagers is null) | |
331 fDamagers= new HashMap(); | |
332 | |
333 if (damager is null) | |
334 fDamagers.remove(contentType); | |
335 else | |
159 | 336 fDamagers.put(stringcast(contentType), cast(Object)damager); |
129 | 337 } |
338 | |
339 /** | |
340 * Registers the given presentation repairer for a particular content type. | |
341 * If there is already a repairer registered for this type, the old repairer | |
342 * is removed first. | |
343 * | |
344 * @param repairer the presentation repairer to register, or <code>null</code> to remove an existing one | |
345 * @param contentType the content type under which to register | |
346 */ | |
347 public void setRepairer(IPresentationRepairer repairer, String contentType) { | |
348 | |
349 Assert.isNotNull(contentType); | |
350 | |
351 if (fRepairers is null) | |
352 fRepairers= new HashMap(); | |
353 | |
354 if (repairer is null) | |
355 fRepairers.remove(contentType); | |
356 else | |
159 | 357 fRepairers.put(stringcast(contentType), cast(Object)repairer); |
129 | 358 } |
359 | |
360 /* | |
361 * @see IPresentationReconciler#install(ITextViewer) | |
362 */ | |
363 public void install(ITextViewer viewer) { | |
159 | 364 Assert.isNotNull(cast(Object)viewer); |
129 | 365 |
366 fViewer= viewer; | |
367 fViewer.addTextInputListener(fInternalListener); | |
159 | 368 |
129 | 369 IDocument document= viewer.getDocument(); |
370 if (document !is null) | |
371 fInternalListener.inputDocumentChanged(null, document); | |
372 } | |
373 | |
374 /* | |
375 * @see IPresentationReconciler#uninstall() | |
376 */ | |
377 public void uninstall() { | |
378 fViewer.removeTextInputListener(fInternalListener); | |
379 | |
380 // Ensure we uninstall all listeners | |
381 fInternalListener.inputDocumentAboutToBeChanged(fViewer.getDocument(), null); | |
382 } | |
383 | |
384 /* | |
385 * @see IPresentationReconciler#getDamager(String) | |
386 */ | |
387 public IPresentationDamager getDamager(String contentType) { | |
388 | |
389 if (fDamagers is null) | |
390 return null; | |
391 | |
134 | 392 return cast(IPresentationDamager) fDamagers.get(contentType); |
129 | 393 } |
394 | |
395 /* | |
396 * @see IPresentationReconciler#getRepairer(String) | |
397 */ | |
398 public IPresentationRepairer getRepairer(String contentType) { | |
399 | |
400 if (fRepairers is null) | |
401 return null; | |
402 | |
134 | 403 return cast(IPresentationRepairer) fRepairers.get(contentType); |
129 | 404 } |
405 | |
406 /** | |
407 * Informs all registered damagers about the document on which they will work. | |
408 * | |
409 * @param document the document on which to work | |
410 */ | |
411 protected void setDocumentToDamagers(IDocument document) { | |
412 if (fDamagers !is null) { | |
413 Iterator e= fDamagers.values().iterator(); | |
414 while (e.hasNext()) { | |
134 | 415 IPresentationDamager damager= cast(IPresentationDamager) e.next(); |
129 | 416 damager.setDocument(document); |
417 } | |
418 } | |
419 } | |
420 | |
421 /** | |
422 * Informs all registered repairers about the document on which they will work. | |
423 * | |
424 * @param document the document on which to work | |
425 */ | |
426 protected void setDocumentToRepairers(IDocument document) { | |
427 if (fRepairers !is null) { | |
428 Iterator e= fRepairers.values().iterator(); | |
429 while (e.hasNext()) { | |
134 | 430 IPresentationRepairer repairer= cast(IPresentationRepairer) e.next(); |
129 | 431 repairer.setDocument(document); |
432 } | |
433 } | |
434 } | |
435 | |
436 /** | |
437 * Constructs a "repair description" for the given damage and returns this | |
438 * description as a text presentation. For this, it queries the partitioning | |
439 * of the damage region and asks the appropriate presentation repairer for | |
440 * each partition to construct the "repair description" for this partition. | |
441 * | |
442 * @param damage the damage to be repaired | |
443 * @param document the document whose presentation must be repaired | |
444 * @return the presentation repair description as text presentation or | |
445 * <code>null</code> if the partitioning could not be computed | |
446 */ | |
447 protected TextPresentation createPresentation(IRegion damage, IDocument document) { | |
448 try { | |
449 if (fRepairers is null || fRepairers.isEmpty()) { | |
450 TextPresentation presentation= new TextPresentation(damage, 100); | |
451 presentation.setDefaultStyleRange(new StyleRange(damage.getOffset(), damage.getLength(), null, null)); | |
452 return presentation; | |
453 } | |
454 | |
455 TextPresentation presentation= new TextPresentation(damage, 1000); | |
456 | |
457 ITypedRegion[] partitioning= TextUtilities.computePartitioning(document, getDocumentPartitioning(), damage.getOffset(), damage.getLength(), false); | |
458 for (int i= 0; i < partitioning.length; i++) { | |
459 ITypedRegion r= partitioning[i]; | |
460 IPresentationRepairer repairer= getRepairer(r.getType()); | |
461 if (repairer !is null) | |
462 repairer.createPresentation(presentation, r); | |
463 } | |
464 | |
465 return presentation; | |
466 | |
467 } catch (BadLocationException x) { | |
468 return null; | |
469 } | |
470 } | |
471 | |
472 | |
473 /** | |
474 * Checks for the first and the last affected partition affected by a | |
475 * document event and calls their damagers. Invalidates everything from the | |
476 * start of the damage for the first partition until the end of the damage | |
477 * for the last partition. | |
478 * | |
479 * @param e the event describing the document change | |
480 * @param optimize <code>true</code> if partition changes should be | |
481 * considered for optimization | |
482 * @return the damaged caused by the change or <code>null</code> if | |
483 * computing the partitioning failed | |
484 * @since 3.0 | |
485 */ | |
486 private IRegion getDamage(DocumentEvent e, bool optimize) { | |
487 int length= e.getText() is null ? 0 : e.getText().length(); | |
159 | 488 |
129 | 489 if (fDamagers is null || fDamagers.isEmpty()) { |
490 length= Math.max(e.getLength(), length); | |
491 length= Math.min(e.getDocument().getLength() - e.getOffset(), length); | |
492 return new Region(e.getOffset(), length); | |
493 } | |
494 | |
495 bool isDeletion= length is 0; | |
496 IRegion damage= null; | |
497 try { | |
498 int offset= e.getOffset(); | |
499 if (isDeletion) | |
500 offset= Math.max(0, offset - 1); | |
501 ITypedRegion partition= getPartition(e.getDocument(), offset); | |
502 IPresentationDamager damager= getDamager(partition.getType()); | |
503 if (damager is null) | |
504 return null; | |
505 | |
506 IRegion r= damager.getDamageRegion(partition, e, fDocumentPartitioningChanged); | |
507 | |
508 if (!fDocumentPartitioningChanged && optimize && !isDeletion) { | |
509 damage= r; | |
510 } else { | |
511 | |
512 int damageEnd= getDamageEndOffset(e); | |
513 | |
514 int parititionDamageEnd= -1; | |
515 if (fChangedDocumentPartitions !is null) | |
516 parititionDamageEnd= fChangedDocumentPartitions.getOffset() + fChangedDocumentPartitions.getLength(); | |
517 | |
518 int end= Math.max(damageEnd, parititionDamageEnd); | |
519 | |
520 damage= end is -1 ? r : new Region(r.getOffset(), end - r.getOffset()); | |
521 } | |
522 | |
523 } catch (BadLocationException x) { | |
524 } | |
525 | |
526 return damage; | |
527 } | |
528 | |
529 /** | |
530 * Returns the end offset of the damage. If a partition has been split by | |
531 * the given document event also the second half of the original | |
532 * partition must be considered. This is achieved by using the remembered | |
533 * partition range. | |
534 * | |
535 * @param e the event describing the change | |
536 * @return the damage end offset (excluding) | |
537 * @exception BadLocationException if method accesses invalid offset | |
538 */ | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
134
diff
changeset
|
539 private int getDamageEndOffset(DocumentEvent e) { |
129 | 540 |
541 IDocument d= e.getDocument(); | |
542 | |
543 int length= 0; | |
544 if (e.getText() !is null) { | |
159 | 545 length= e.getText().length; |
129 | 546 if (length > 0) |
547 -- length; | |
548 } | |
549 | |
550 ITypedRegion partition= getPartition(d, e.getOffset() + length); | |
551 int endOffset= partition.getOffset() + partition.getLength(); | |
552 if (endOffset is e.getOffset()) | |
553 return -1; | |
554 | |
555 int end= fRememberedPosition is null ? -1 : fRememberedPosition.getOffset() + fRememberedPosition.getLength(); | |
556 if (endOffset < end && end < d.getLength()) | |
557 partition= getPartition(d, end); | |
558 | |
559 IPresentationDamager damager= getDamager(partition.getType()); | |
560 if (damager is null) | |
561 return -1; | |
562 | |
563 IRegion r= damager.getDamageRegion(partition, e, fDocumentPartitioningChanged); | |
564 | |
565 return r.getOffset() + r.getLength(); | |
566 } | |
567 | |
568 /** | |
569 * Processes the given damage. | |
570 * @param damage the damage to be repaired | |
571 * @param document the document whose presentation must be repaired | |
572 */ | |
573 private void processDamage(IRegion damage, IDocument document) { | |
574 if (damage !is null && damage.getLength() > 0) { | |
575 TextPresentation p= createPresentation(damage, document); | |
576 if (p !is null) | |
577 applyTextRegionCollection(p); | |
578 } | |
579 } | |
580 | |
581 /** | |
582 * Applies the given text presentation to the text viewer the presentation | |
583 * reconciler is installed on. | |
584 * | |
585 * @param presentation the text presentation to be applied to the text viewer | |
586 */ | |
587 private void applyTextRegionCollection(TextPresentation presentation) { | |
588 fViewer.changeTextPresentation(presentation, false); | |
589 } | |
590 | |
591 /** | |
592 * Returns the partition for the given offset in the given document. | |
593 * | |
594 * @param document the document | |
595 * @param offset the offset | |
596 * @return the partition | |
597 * @throws BadLocationException if offset is invalid in the given document | |
598 * @since 3.0 | |
599 */ | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
134
diff
changeset
|
600 private ITypedRegion getPartition(IDocument document, int offset) { |
129 | 601 return TextUtilities.getPartition(document, getDocumentPartitioning(), offset, false); |
602 } | |
603 } |