View | Details | Raw Unified | Return to bug 372128 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java (-50 / +170 lines)
Lines 9-17 Link Here
9
 *     Christian Plesner Hansen (plesner@quenta.org) - initial API and implementation
9
 *     Christian Plesner Hansen (plesner@quenta.org) - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jface.text.source;
11
package org.eclipse.jface.text.source;
12
import java.util.HashSet;
13
import java.util.Set;
14
15
import org.eclipse.core.runtime.Assert;
12
import org.eclipse.core.runtime.Assert;
16
13
17
import org.eclipse.jface.text.BadLocationException;
14
import org.eclipse.jface.text.BadLocationException;
Lines 97-102 Link Here
97
		this(chars, IDocumentExtension3.DEFAULT_PARTITIONING);
94
		this(chars, IDocumentExtension3.DEFAULT_PARTITIONING);
98
	}
95
	}
99
96
97
	/**
98
	 * @see org.eclipse.jface.text.source.ICharacterPairMatcherExtension#isMatchedChar(char)
99
	 * @since 3.8
100
	 */
101
	public boolean isMatchedChar(char ch) {
102
		return fPairs.contains(ch);
103
	}
104
100
	/* @see ICharacterPairMatcher#match(IDocument, int) */
105
	/* @see ICharacterPairMatcher#match(IDocument, int) */
101
	public IRegion match(IDocument doc, int offset) {
106
	public IRegion match(IDocument doc, int offset) {
102
		if (doc == null || offset < 0 || offset > doc.getLength()) return null;
107
		if (doc == null || offset < 0 || offset > doc.getLength()) return null;
Lines 132-169 Link Here
132
		if (document == null || offset < 0 || offset > document.getLength())
137
		if (document == null || offset < 0 || offset > document.getLength())
133
			return null;
138
			return null;
134
139
135
		int start;
140
		//maybe a bracket is selected
136
		int end;
141
		IRegion region= match(document, offset, length);
137
		if (length >= 0) {
142
		fAnchor= ICharacterPairMatcher.LEFT; //always set the anchor to LEFT
138
			start= offset;
143
		if (region != null) {
139
			end= offset + length;
144
			return region;
140
		} else {
141
			end= offset;
142
			start= offset + length;
143
		}
145
		}
144
146
145
		int sourceCaretOffset= offset + length;
147
		//bracket is not selected
146
		int adjustment= getOffsetAdjustment(document, sourceCaretOffset, length);
147
		sourceCaretOffset+= adjustment;
148
149
		try {
148
		try {
150
			for (int offset1= sourceCaretOffset; offset1 >= 0; offset1--) {
149
			final String partition1= TextUtilities.getContentType(document, fPartitioning, offset, false);
151
				char prevChar= document.getChar(Math.max(offset1 - 1, 0));
150
			final DocumentPartitionAccessor partDoc= new DocumentPartitionAccessor(document, fPartitioning, partition1);
152
				if (fPairs.contains(prevChar) && fPairs.isStartCharacter(prevChar)) {
151
			return findEnclosingPeers(document, partDoc, offset, length, 0, document.getLength());
153
					IRegion match= performMatch(document, offset1);
154
					if (match != null) {
155
						int matchOffset= match.getOffset();
156
						int matchLength= match.getLength();
157
						if ((matchOffset <= start) && (matchOffset + matchLength > start) && (matchOffset < end) && (matchOffset + matchLength >= end)) {
158
							return match;
159
						}
160
					}
161
				}
162
			}
163
		} catch (BadLocationException ble) {
152
		} catch (BadLocationException ble) {
153
			fAnchor= -1;
164
			return null;
154
			return null;
165
		}
155
		}
166
		return null;
156
	}
157
158
	/**
159
	 * @see org.eclipse.jface.text.source.ICharacterPairMatcherExtension#isRecomputationOfEnclosingPairRequired(org.eclipse.jface.text.IDocument,
160
	 *      org.eclipse.jface.text.IRegion, org.eclipse.jface.text.IRegion)
161
	 * @since 3.8
162
	 */
163
	public boolean isRecomputationOfEnclosingPairRequired(IDocument document, IRegion currentSelection, IRegion previousSelection) {
164
		int previousCaretOffset= previousSelection.getOffset() + previousSelection.getLength();
165
		int currentCaretOffset= currentSelection.getOffset() + currentSelection.getLength();
166
167
		try {
168
			String prevContentType= TextUtilities.getContentType(document, fPartitioning, previousCaretOffset, false);
169
			String currContentType= TextUtilities.getContentType(document, fPartitioning, currentCaretOffset, false);
170
171
			if (!prevContentType.equals(currContentType))
172
				return true;
173
174
			int start;
175
			int end;
176
			if (currentCaretOffset > previousCaretOffset) {
177
				start= previousCaretOffset;
178
				end= currentCaretOffset;
179
			} else {
180
				start= currentCaretOffset;
181
				end= previousCaretOffset;
182
			}
183
			for (int i= start; i < end; i++) {
184
				if (isMatchedChar(document.getChar(i))) {
185
					return true;
186
				}
187
			}
188
		} catch (BadLocationException e) {
189
			//do nothing
190
		}
191
		return false;
167
	}
192
	}
168
193
169
	/**
194
	/**
Lines 261-266 Link Here
261
		return -1;
286
		return -1;
262
	}
287
	}
263
288
289
	/*
290
	 * Performs the actual work of finding enclosing peer characters for #findEnclosingPeerCharacters(IDocument, int, int).
291
	 */
292
	private IRegion findEnclosingPeers(IDocument document, DocumentPartitionAccessor doc, int offset, int length, int lowerBoundary, int upperBoundary) throws BadLocationException {
293
		char[] pairs= fPairs.fPairs;
294
	
295
		int start;
296
		int end;
297
		if (length >= 0) {
298
			start= offset;
299
			end= offset + length;
300
		} else {
301
			end= offset;
302
			start= offset + length;
303
		}
304
	
305
		boolean lowerFound= false;
306
		boolean upperFound= false;
307
		int[][] counts= new int[pairs.length][2];
308
		int pos1= doc.getNextPosition(start, false);
309
		int pos2= start;
310
	
311
		while ((pos1 >= lowerBoundary && !lowerFound) || (pos2 < upperBoundary && !upperFound)) {
312
			for (int i= 0; i < counts.length; i++) {
313
				counts[i][0]= counts[i][1]= 0;
314
			}
315
	
316
			outer1: while (pos1 >= lowerBoundary && !lowerFound) {
317
				final char c= doc.getChar(pos1);
318
				int i= getCharacterType(c, document, pos1);
319
				if (i != -1 && doc.inPartition(pos1)) {
320
					if (i % 2 == 0) {
321
						counts[i / 2][0]--; //start
322
					} else {
323
						counts[i / 2][0]++; //end
324
					}
325
					for (int j= 0; j < counts.length; j++) {
326
						if (counts[j][0] == -1) {
327
							lowerFound= true;
328
							break outer1;
329
						}
330
					}
331
				}
332
				pos1= doc.getNextPosition(pos1, false);
333
			}
334
	
335
			outer2: while (pos2 < upperBoundary && !upperFound) {
336
				final char c= doc.getChar(pos2);
337
				int i= getCharacterType(c, document, pos2);
338
				if (i != -1 && doc.inPartition(pos2)) {
339
					if (i % 2 == 0) {
340
						counts[i / 2][1]++; //start
341
					} else {
342
						counts[i / 2][1]--; //end
343
					}
344
					for (int j= 0; j < counts.length; j++) {
345
						if (counts[j][1] == -1 && counts[j][0] == -1) {
346
							upperFound= true;
347
							break outer2;
348
						}
349
					}
350
				}
351
				pos2= doc.getNextPosition(pos2, true);
352
			}
353
	
354
			if (pos1 > start || pos2 < end) {
355
				//match inside selection => discard
356
				pos1= doc.getNextPosition(pos1, false);
357
				pos2= doc.getNextPosition(pos2, true);
358
				lowerFound= false;
359
				upperFound= false;
360
			}
361
		}
362
		pos2++;
363
		if (pos1 < lowerBoundary || pos2 > upperBoundary)
364
			return null;
365
		return new Region(pos1, pos2 - pos1);
366
	}
367
368
	/**
369
	 * Determines whether the given character is a start character or an end character or none of
370
	 * these.
371
	 * 
372
	 * <p>
373
	 * Clients can override this method to handle characters which may have special meaning in some
374
	 * situations. E.g. In Java '<' is used as an angular bracket and as well as less-than operator.
375
	 * </p>
376
	 * 
377
	 * @param ch the character
378
	 * @param document the document
379
	 * @param offset the offset in document
380
	 * @return 0 if start character, 1 if end character and -1 if neither a start or an end character
381
	 * @since 3.8
382
	 */
383
	protected int getCharacterType(char ch, IDocument document, int offset) {
384
		char[] pairs= fPairs.fPairs;
385
		for (int i= 0; i < pairs.length; i++) {
386
			if (pairs[i] == ch) {
387
				return i;
388
			}
389
		}
390
		return -1;
391
	}
392
264
	/* @see ICharacterPairMatcher#getAnchor() */
393
	/* @see ICharacterPairMatcher#getAnchor() */
265
	public int getAnchor() {
394
	public int getAnchor() {
266
		return fAnchor;
395
		return fAnchor;
Lines 285-290 Link Here
285
		private final IDocument fDocument;
414
		private final IDocument fDocument;
286
		private final String fPartitioning, fPartition;
415
		private final String fPartitioning, fPartition;
287
		private ITypedRegion fCachedPartition;
416
		private ITypedRegion fCachedPartition;
417
		private int fLength;
288
418
289
		/**
419
		/**
290
		 * Creates a new partitioned document for the specified document.
420
		 * Creates a new partitioned document for the specified document.
Lines 298-303 Link Here
298
			fDocument= doc;
428
			fDocument= doc;
299
			fPartitioning= partitioning;
429
			fPartitioning= partitioning;
300
			fPartition= partition;
430
			fPartition= partition;
431
			fLength= doc.getLength();
301
		}
432
		}
302
433
303
		/**
434
		/**
Lines 338-344 Link Here
338
		}
469
		}
339
470
340
		/**
471
		/**
341
		 * Returns the next position to query in the search.  The position
472
		 * Returns the next position to query in the search. The position
342
		 * is not guaranteed to be in this document's partition.
473
		 * is not guaranteed to be in this document's partition.
343
		 *
474
		 *
344
		 * @param pos an offset within the document
475
		 * @param pos an offset within the document
Lines 347-354 Link Here
347
		 */
478
		 */
348
		public int getNextPosition(int pos, boolean searchForward) {
479
		public int getNextPosition(int pos, boolean searchForward) {
349
			final ITypedRegion partition= getPartition(pos);
480
			final ITypedRegion partition= getPartition(pos);
350
			if (partition == null) return simpleIncrement(pos, searchForward);
481
			if (partition == null || fPartition.equals(partition.getType()))
351
			if (fPartition.equals(partition.getType()))
352
				return simpleIncrement(pos, searchForward);
482
				return simpleIncrement(pos, searchForward);
353
			if (searchForward) {
483
			if (searchForward) {
354
				int end= partition.getOffset() + partition.getLength();
484
				int end= partition.getOffset() + partition.getLength();
Lines 376-382 Link Here
376
		 */
506
		 */
377
		private ITypedRegion getPartition(int pos) {
507
		private ITypedRegion getPartition(int pos) {
378
			if (fCachedPartition == null || !contains(fCachedPartition, pos)) {
508
			if (fCachedPartition == null || !contains(fCachedPartition, pos)) {
379
				Assert.isTrue(pos >= 0 && pos <= fDocument.getLength());
509
				Assert.isTrue(pos >= 0 && pos <= fLength);
380
				try {
510
				try {
381
					fCachedPartition= TextUtilities.getPartition(fDocument, fPartitioning, pos, false);
511
					fCachedPartition= TextUtilities.getPartition(fDocument, fPartitioning, pos, false);
382
				} catch (BadLocationException e) {
512
				} catch (BadLocationException e) {
Lines 405-432 Link Here
405
		}
535
		}
406
536
407
		/**
537
		/**
408
		 * Returns true if the specified character pair occurs in one
538
		 * Returns true if the specified character occurs in one of the character pairs.
409
		 * of the character pairs.
539
		 * 
410
		 *
411
		 * @param c a character
540
		 * @param c a character
412
		 * @return true exactly if the character occurs in one of the pairs
541
		 * @return true exactly if the character occurs in one of the pairs
413
		 */
542
		 */
414
		public boolean contains(char c) {
543
		public boolean contains(char c) {
415
			return getAllCharacters().contains(new Character(c));
544
			char[] pairs= fPairs;
416
		}
545
			for (int i= 0, n= pairs.length; i < n; i++) {
417
546
				if (c == pairs[i])
418
		private Set/*<Character>*/ fCharsCache= null;
547
					return true;
419
		/**
420
		 * @return A set containing all characters occurring in character pairs.
421
		 */
422
		private Set/*<Character>*/ getAllCharacters() {
423
			if (fCharsCache == null) {
424
				Set/*<Character>*/ set= new HashSet/*<Character>*/();
425
				for (int i= 0; i < fPairs.length; i++)
426
					set.add(new Character(fPairs[i]));
427
				fCharsCache= set;
428
			}
548
			}
429
			return fCharsCache;
549
			return false;
430
		}
550
		}
431
551
432
		/**
552
		/**
(-)a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ICharacterPairMatcherExtension.java (+28 lines)
Lines 49-52 Link Here
49
	 *         enclosing pair
49
	 *         enclosing pair
50
	 */
50
	 */
51
	IRegion findEnclosingPeerCharacters(IDocument document, int offset, int length);
51
	IRegion findEnclosingPeerCharacters(IDocument document, int offset, int length);
52
53
	/**
54
	 * Checks whether the character is one of the characters matched by the pair matcher.
55
	 * 
56
	 * @param ch the character
57
	 * @return <code>true</code> if the the character is one of the characters matched by the pair
58
	 *         matcher, and <code>false</code> otherwise
59
	 */
60
	boolean isMatchedChar(char ch);
61
62
	/**
63
	 * Computes whether a client needs to recompute enclosing pair after a selection change in the
64
	 * document.
65
	 * 
66
	 * <p>
67
	 * This is intended to be quick test to determine whether a re-computation is required, as the
68
	 * re-computation at each selection change via a
69
	 * {@link #findEnclosingPeerCharacters(IDocument, int, int)} call can be expensive for some
70
	 * clients.
71
	 * </p>
72
	 * 
73
	 * @param document the document to work on
74
	 * @param currentSelection the current selection in the document
75
	 * @param previousSelection the previous selection in the document
76
	 * @return <code>true</code> if enclosing pair needs to be recomputed, <code>false</code>
77
	 *         otherwise
78
	 */
79
	boolean isRecomputationOfEnclosingPairRequired(IDocument document, IRegion currentSelection, IRegion previousSelection);
52
}
80
}
(-)a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/MatchingCharacterPainter.java (-1 / +140 lines)
Lines 20-32 Link Here
20
import org.eclipse.swt.graphics.Rectangle;
20
import org.eclipse.swt.graphics.Rectangle;
21
21
22
import org.eclipse.jface.text.BadLocationException;
22
import org.eclipse.jface.text.BadLocationException;
23
import org.eclipse.jface.text.DocumentEvent;
23
import org.eclipse.jface.text.IDocument;
24
import org.eclipse.jface.text.IDocument;
24
import org.eclipse.jface.text.IPaintPositionManager;
25
import org.eclipse.jface.text.IPaintPositionManager;
25
import org.eclipse.jface.text.IPainter;
26
import org.eclipse.jface.text.IPainter;
26
import org.eclipse.jface.text.IRegion;
27
import org.eclipse.jface.text.IRegion;
28
import org.eclipse.jface.text.ITextInputListener;
29
import org.eclipse.jface.text.ITextListener;
27
import org.eclipse.jface.text.ITextViewerExtension5;
30
import org.eclipse.jface.text.ITextViewerExtension5;
28
import org.eclipse.jface.text.Position;
31
import org.eclipse.jface.text.Position;
29
import org.eclipse.jface.text.Region;
32
import org.eclipse.jface.text.Region;
33
import org.eclipse.jface.text.TextEvent;
30
34
31
/**
35
/**
32
 * Highlights the peer character matching the character near the caret position.
36
 * Highlights the peer character matching the character near the caret position.
Lines 62-67 Link Here
62
	/** Whether a character is present at caret location or not. */
66
	/** Whether a character is present at caret location or not. */
63
	private boolean fCharacterPresentAtCaretLocation;
67
	private boolean fCharacterPresentAtCaretLocation;
64
68
69
	/**
70
	 * The document this painter is associated with.
71
	 * 
72
	 * @since 3.8
73
	 */
74
	private IDocument fDocument;
75
76
	/**
77
	 * The previous selection, used to determine the need for computing enclosing brackets.
78
	 * 
79
	 * @since 3.8
80
	 */
81
	private IRegion fPreviousSelection;
82
83
	/**
84
	 * Previous length of the document this painter is associated with.
85
	 * 
86
	 * @since 3.8
87
	 */
88
	private int fPreviousLenghtOfDocument;
89
90
	/**
91
	 * Whether the input document has been replaced or not.
92
	 * 
93
	 * @since 3.8
94
	 */
95
	private boolean fDocumentChanged;
96
97
	/**
98
	 * The text viewer change listener.
99
	 * 
100
	 * @since 3.8
101
	 */
102
	private TextListener fTextListener;
65
103
66
	/**
104
	/**
67
	 * Creates a new MatchingCharacterPainter for the given source viewer using the given character
105
	 * Creates a new MatchingCharacterPainter for the given source viewer using the given character
Lines 75-80 Link Here
75
		fSourceViewer= sourceViewer;
113
		fSourceViewer= sourceViewer;
76
		fMatcher= matcher;
114
		fMatcher= matcher;
77
		fTextWidget= sourceViewer.getTextWidget();
115
		fTextWidget= sourceViewer.getTextWidget();
116
117
		fDocument= fSourceViewer.getDocument();
118
119
		if (fMatcher instanceof ICharacterPairMatcherExtension) {
120
			fTextListener= new TextListener();
121
			fSourceViewer.addTextInputListener(fTextListener);
122
			fSourceViewer.addTextListener(fTextListener);
123
		}
78
	}
124
	}
79
125
80
	/**
126
	/**
Lines 112-117 Link Here
112
	 */
158
	 */
113
	public void dispose() {
159
	public void dispose() {
114
		if (fMatcher != null) {
160
		if (fMatcher != null) {
161
			if (fMatcher instanceof ICharacterPairMatcherExtension) {
162
				fSourceViewer.removeTextInputListener(fTextListener);
163
				fSourceViewer.removeTextListener(fTextListener);
164
			}
165
115
			fMatcher.clear();
166
			fMatcher.clear();
116
			fMatcher= null;
167
			fMatcher= null;
117
		}
168
		}
Lines 262-268 Link Here
262
	 */
313
	 */
263
	public void paint(int reason) {
314
	public void paint(int reason) {
264
315
265
		IDocument document= fSourceViewer.getDocument();
316
		IDocument document= fDocument;
266
		if (document == null) {
317
		if (document == null) {
267
			deactivate(false);
318
			deactivate(false);
268
			return;
319
			return;
Lines 277-282 Link Here
277
			pair= matcher.match(document, selection.getOffset(), selection.getLength());
328
			pair= matcher.match(document, selection.getOffset(), selection.getLength());
278
			characterPresentAtCaretLocation= (pair != null);
329
			characterPresentAtCaretLocation= (pair != null);
279
			if (pair == null && fHighlightEnclosingPeerCharcters) {
330
			if (pair == null && fHighlightEnclosingPeerCharcters) {
331
332
				int length= document.getLength();
333
				boolean lengthChanged= length != fPreviousLenghtOfDocument;
334
				fPreviousLenghtOfDocument= length;
335
336
				if (reason != IPainter.CONFIGURATION && !fDocumentChanged && !lengthChanged && selection.equals(fPreviousSelection)) {
337
					return;
338
				}
339
340
				if (reason == IPainter.TEXT_CHANGE) {
341
					fPreviousSelection= selection;
342
					return;
343
				}
344
345
				fDocumentChanged= false;
346
				if (reason != IPainter.CONFIGURATION && !lengthChanged && fPreviousSelection != null && reason != IPainter.INTERNAL) {
347
					if (!matcher.isRecomputationOfEnclosingPairRequired(document, selection, fPreviousSelection)) {
348
						fPreviousSelection= selection;
349
						return;
350
					}
351
				}
280
				pair= matcher.findEnclosingPeerCharacters(document, selection.getOffset(), selection.getLength());
352
				pair= matcher.findEnclosingPeerCharacters(document, selection.getOffset(), selection.getLength());
281
			}
353
			}
282
		} else {
354
		} else {
Lines 288-293 Link Here
288
			characterPresentAtCaretLocation= (pair != null);
360
			characterPresentAtCaretLocation= (pair != null);
289
		}
361
		}
290
362
363
		fPreviousSelection= selection;
291
		if (pair == null) {
364
		if (pair == null) {
292
			deactivate(true);
365
			deactivate(true);
293
			return;
366
			return;
Lines 340-343 Link Here
340
	public void setPositionManager(IPaintPositionManager manager) {
413
	public void setPositionManager(IPaintPositionManager manager) {
341
		fPaintPositionManager= manager;
414
		fPaintPositionManager= manager;
342
	}
415
	}
416
417
	private class TextListener implements ITextListener, ITextInputListener {
418
419
		/**
420
		 * @see org.eclipse.jface.text.ITextInputListener#inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument,
421
		 *      org.eclipse.jface.text.IDocument)
422
		 * @since 3.8
423
		 */
424
		public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
425
			//do nothing
426
		}
427
428
		/**
429
		 * @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument,
430
		 *      org.eclipse.jface.text.IDocument)
431
		 * @since 3.8
432
		 */
433
		public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
434
			fDocument= newInput;
435
			fDocumentChanged= true;
436
		}
437
438
		/**
439
		 * @see org.eclipse.jface.text.ITextListener#textChanged(org.eclipse.jface.text.TextEvent)
440
		 * @since 3.8
441
		 */
442
		public void textChanged(TextEvent event) {
443
			if (!fHighlightEnclosingPeerCharcters || !(fMatcher instanceof ICharacterPairMatcherExtension))
444
				return;
445
446
			String text= event.getText();
447
			String replacedText= event.getReplacedText();
448
449
			boolean viewerRedrawState= event.getViewerRedrawState();
450
			DocumentEvent documentEvent= event.getDocumentEvent();
451
			if (documentEvent == null && !viewerRedrawState)
452
				return;
453
454
			ICharacterPairMatcherExtension matcher= (ICharacterPairMatcherExtension)fMatcher;
455
			boolean found= searchForCharacters(text, matcher) || searchForCharacters(replacedText, matcher);
456
457
			if (found || (documentEvent == null && viewerRedrawState)) {
458
				paint(IPainter.INTERNAL);
459
			}
460
		}
461
462
		/**
463
		 * Searches for matched characters in the given string.
464
		 * 
465
		 * @param text the string to search
466
		 * @param matcher the pair matcher
467
		 * @return <code>true</code> if a matched character is found, <code>false</code> otherwise
468
		 * 
469
		 * @since 3.8
470
		 */
471
		private boolean searchForCharacters(String text, ICharacterPairMatcherExtension matcher) {
472
			if (text == null)
473
				return false;
474
			for (int i= 0; i < text.length(); i++) {
475
				if (matcher.isMatchedChar(text.charAt(i))) {
476
					return true;
477
				}
478
			}
479
			return false;
480
		}
481
	}
343
}
482
}
(-)a/org.eclipse.text.tests/src/org/eclipse/text/tests/CopyOnWriteTextStoreTest.java (-4 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
2
 * Copyright (c) 2005, 2012 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 31-37 Link Here
31
			super(new GapTextStore());
31
			super(new GapTextStore());
32
		}
32
		}
33
		ITextStore getStore() {
33
		ITextStore getStore() {
34
			return fTextStore;
34
			return (ITextStore)new Accessor(this, CopyOnWriteTextStore.class).get("fTextStore");
35
		}
35
		}
36
		String get() {
36
		String get() {
37
			return get(0, getLength());
37
			return get(0, getLength());
Lines 68-74 Link Here
68
		// check that underlying text store is not modifiable
68
		// check that underlying text store is not modifiable
69
		boolean failed= false;
69
		boolean failed= false;
70
		try {
70
		try {
71
			fText.getStore().replace(0,0,null);
71
			fText.getStore().replace(0, 0, null);
72
		} catch (UnsupportedOperationException uoe) {
72
		} catch (UnsupportedOperationException uoe) {
73
			failed= true;
73
			failed= true;
74
		}
74
		}
Lines 91-97 Link Here
91
		// check that underlying text store is not modifiable
91
		// check that underlying text store is not modifiable
92
		boolean failed= false;
92
		boolean failed= false;
93
		try {
93
		try {
94
			fText.getStore().replace(0,0,null);
94
			fText.getStore().replace(0, 0, null);
95
		} catch (UnsupportedOperationException uoe) {
95
		} catch (UnsupportedOperationException uoe) {
96
			failed= true;
96
			failed= true;
97
		}
97
		}
(-)a/org.eclipse.text/src/org/eclipse/jface/text/CopyOnWriteTextStore.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
2
 * Copyright (c) 2005, 2012 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 107-113 Link Here
107
	}
107
	}
108
108
109
	/** The underlying "real" text store */
109
	/** The underlying "real" text store */
110
	protected ITextStore fTextStore= new StringTextStore();
110
	private ITextStore fTextStore;
111
111
112
	/** A modifiable <code>ITextStore</code> instance */
112
	/** A modifiable <code>ITextStore</code> instance */
113
	private final ITextStore fModifiableTextStore;
113
	private final ITextStore fModifiableTextStore;

Return to bug 372128