13
13
*******************************************************************************/
14
14
package org .eclipse .core .internal .filebuffers ;
15
15
16
+ import java .util .List ;
17
+ import java .util .Map ;
18
+
16
19
import org .eclipse .jface .text .BadLocationException ;
17
20
import org .eclipse .jface .text .BadPartitioningException ;
18
21
import org .eclipse .jface .text .BadPositionCategoryException ;
19
22
import org .eclipse .jface .text .Document ;
23
+ import org .eclipse .jface .text .DocumentEvent ;
20
24
import org .eclipse .jface .text .DocumentRewriteSession ;
21
25
import org .eclipse .jface .text .DocumentRewriteSessionType ;
22
26
import org .eclipse .jface .text .IDocumentExtension4 ;
@@ -38,6 +42,97 @@ public class SynchronizableDocument extends Document implements ISynchronizable
38
42
39
43
private Object fLockObject ;
40
44
45
+ @ Override
46
+ protected void updateDocumentStructures (DocumentEvent event ) {
47
+ Object lockObject = getLockObject ();
48
+ if (lockObject == null ) {
49
+ super .updateDocumentStructures (event );
50
+ return ;
51
+ }
52
+ synchronized (lockObject ) {
53
+ super .updateDocumentStructures (event );
54
+ }
55
+ }
56
+
57
+ @ Override
58
+ public void removePositionCategory (String category ) throws BadPositionCategoryException {
59
+ Object lockObject = getLockObject ();
60
+ if (lockObject == null ) {
61
+ super .removePositionCategory (category );
62
+ return ;
63
+ }
64
+ synchronized (lockObject ) {
65
+ super .removePositionCategory (category );
66
+ }
67
+ }
68
+
69
+ @ Override
70
+ public String [] getPositionCategories () {
71
+ Object lockObject = getLockObject ();
72
+ if (lockObject == null ) {
73
+ return super .getPositionCategories ();
74
+ }
75
+ synchronized (lockObject ) {
76
+ return super .getPositionCategories ();
77
+ }
78
+ }
79
+
80
+ @ Override
81
+ protected Map <String , List <Position >> getDocumentManagedPositions () {
82
+ Object lockObject = getLockObject ();
83
+ if (lockObject == null ) {
84
+ return super .getDocumentManagedPositions ();
85
+ }
86
+ synchronized (lockObject ) {
87
+ return super .getDocumentManagedPositions ();
88
+ }
89
+ }
90
+
91
+ @ Override
92
+ public boolean containsPositionCategory (String category ) {
93
+ Object lockObject = getLockObject ();
94
+ if (lockObject == null ) {
95
+ return super .containsPositionCategory (category );
96
+ }
97
+ synchronized (lockObject ) {
98
+ return super .containsPositionCategory (category );
99
+ }
100
+ }
101
+
102
+ @ Override
103
+ public boolean containsPosition (String category , int offset , int length ) {
104
+ Object lockObject = getLockObject ();
105
+ if (lockObject == null ) {
106
+ return super .containsPosition (category , offset , length );
107
+ }
108
+ synchronized (lockObject ) {
109
+ return super .containsPosition (category , offset , length );
110
+ }
111
+ }
112
+
113
+ @ Override
114
+ public int computeIndexInCategory (String category , int offset ) throws BadLocationException , BadPositionCategoryException {
115
+ Object lockObject = getLockObject ();
116
+ if (lockObject == null ) {
117
+ return super .computeIndexInCategory (category , offset );
118
+ }
119
+ synchronized (lockObject ) {
120
+ return super .computeIndexInCategory (category , offset );
121
+ }
122
+ }
123
+
124
+ @ Override
125
+ public void addPositionCategory (String category ) {
126
+ Object lockObject = getLockObject ();
127
+ if (lockObject == null ) {
128
+ super .addPositionCategory (category );
129
+ return ;
130
+ }
131
+ synchronized (lockObject ) {
132
+ super .addPositionCategory (category );
133
+ }
134
+ }
135
+
41
136
@ Override
42
137
public synchronized void setLockObject (Object lockObject ) {
43
138
fLockObject = lockObject ;
0 commit comments