Merged "Open PHP Declaration" and "Open Include File" into one action "Open Declarati...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / PartiallySynchronizedDocument.java
1 /**********************************************************************
2 Copyright (c) 2000, 2003 IBM Corp. and others.
3 All rights reserved. This program and the accompanying materials
4 are made available under the terms of the Common Public License v1.0
5 which accompanies this distribution, and is available at
6 http://www.eclipse.org/legal/cpl-v10.html
7
8 Contributors:
9         IBM Corporation - Initial implementation
10 **********************************************************************/
11 package net.sourceforge.phpeclipse.phpeditor;
12
13 import org.eclipse.jface.text.BadLocationException;
14 import org.eclipse.jface.text.BadPositionCategoryException;
15 import org.eclipse.jface.text.Document;
16 import org.eclipse.jface.text.ISynchronizable;
17 import org.eclipse.jface.text.Position;
18
19
20 /**
21  * Document that can also be used by a background reconciler.
22  */
23 public class PartiallySynchronizedDocument extends Document implements ISynchronizable {
24     
25     private final Object fInternalLockObject= new Object();
26     private Object fLockObject;
27     
28     /*
29      * @see org.eclipse.jface.text.ISynchronizable#setLockObject(java.lang.Object)
30      */
31     public void setLockObject(Object lockObject) {
32         fLockObject= lockObject;
33     }
34
35     /*
36      * @see org.eclipse.jface.text.ISynchronizable#getLockObject()
37      */
38     public Object getLockObject() {
39         return fLockObject == null ? fInternalLockObject : fLockObject;
40     }
41         
42         /*
43          * @see IDocumentExtension#startSequentialRewrite(boolean)
44          */
45         public void startSequentialRewrite(boolean normalized) {
46             synchronized (getLockObject()) {
47                 super.startSequentialRewrite(normalized);
48             }
49         }
50
51         /*
52          * @see IDocumentExtension#stopSequentialRewrite()
53          */
54         public void stopSequentialRewrite() {
55                 synchronized (getLockObject()) {
56             super.stopSequentialRewrite();
57         }
58     }
59         
60         /*
61          * @see IDocument#get()
62          */
63         public String get() {
64                 synchronized (getLockObject()) {
65             return super.get();
66         }
67     }
68         
69         /*
70          * @see IDocument#get(int, int)
71          */
72         public String get(int offset, int length) throws BadLocationException {
73                 synchronized (getLockObject()) {
74             return super.get(offset, length);
75         }
76         }
77         
78         /*
79          * @see IDocument#getChar(int)
80          */
81         public char getChar(int offset) throws BadLocationException {
82                 synchronized (getLockObject()) {
83             return super.getChar(offset);
84         }
85         }
86         
87         /*
88          * @see IDocument#replace(int, int, String)
89          */
90         public void replace(int offset, int length, String text) throws BadLocationException {
91                 synchronized (getLockObject()) {
92             super.replace(offset, length, text);
93         }
94         }
95         
96         /*
97          * @see IDocument#set(String)
98          */
99         public void set(String text) {
100                 synchronized (getLockObject()) {
101             super.set(text);
102         }
103         }
104         
105         /*
106          * @see org.eclipse.jface.text.AbstractDocument#addPosition(java.lang.String, org.eclipse.jface.text.Position)
107          */
108         public void addPosition(String category, Position position) throws BadLocationException, BadPositionCategoryException {
109                 synchronized (getLockObject()) {
110             super.addPosition(category, position);
111         }
112         }
113         
114         /*
115          * @see org.eclipse.jface.text.AbstractDocument#removePosition(java.lang.String, org.eclipse.jface.text.Position)
116          */
117         public void removePosition(String category, Position position) throws BadPositionCategoryException {
118                 synchronized (getLockObject()) {
119             super.removePosition(category, position);
120         }
121         }
122         
123         /*
124          * @see org.eclipse.jface.text.AbstractDocument#getPositions(java.lang.String)
125          */
126         public Position[] getPositions(String category) throws BadPositionCategoryException {
127                 synchronized (getLockObject()) {
128             return super.getPositions(category);
129         }
130         }
131 }