1 11 package org.eclipse.jdt.internal.ui.javaeditor; 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 23 public class PartiallySynchronizedDocument extends Document implements ISynchronizable { 24 25 private final Object fInternalLockObject= new Object (); 26 private Object fLockObject; 27 28 31 public void setLockObject(Object lockObject) { 32 fLockObject= lockObject; 33 } 34 35 38 public Object getLockObject() { 39 return fLockObject == null ? fInternalLockObject : fLockObject; 40 } 41 42 45 public void startSequentialRewrite(boolean normalized) { 46 synchronized (getLockObject()) { 47 super.startSequentialRewrite(normalized); 48 } 49 } 50 51 54 public void stopSequentialRewrite() { 55 synchronized (getLockObject()) { 56 super.stopSequentialRewrite(); 57 } 58 } 59 60 63 public String get() { 64 synchronized (getLockObject()) { 65 return super.get(); 66 } 67 } 68 69 72 public String get(int offset, int length) throws BadLocationException { 73 synchronized (getLockObject()) { 74 return super.get(offset, length); 75 } 76 } 77 78 81 public char getChar(int offset) throws BadLocationException { 82 synchronized (getLockObject()) { 83 return super.getChar(offset); 84 } 85 } 86 87 91 public long getModificationStamp() { 92 synchronized (getLockObject()) { 93 return super.getModificationStamp(); 94 } 95 } 96 97 100 public void replace(int offset, int length, String text) throws BadLocationException { 101 synchronized (getLockObject()) { 102 super.replace(offset, length, text); 103 } 104 } 105 106 109 public void replace(int offset, int length, String text, long modificationStamp) throws BadLocationException { 110 synchronized (getLockObject()) { 111 super.replace(offset, length, text, modificationStamp); 112 } 113 } 114 115 118 public void set(String text) { 119 synchronized (getLockObject()) { 120 super.set(text); 121 } 122 } 123 124 127 public void set(String text, long modificationStamp) { 128 synchronized (getLockObject()) { 129 super.set(text, modificationStamp); 130 } 131 } 132 133 136 public void addPosition(String category, Position position) throws BadLocationException, BadPositionCategoryException { 137 synchronized (getLockObject()) { 138 super.addPosition(category, position); 139 } 140 } 141 142 145 public void removePosition(String category, Position position) throws BadPositionCategoryException { 146 synchronized (getLockObject()) { 147 super.removePosition(category, position); 148 } 149 } 150 151 154 public Position[] getPositions(String category) throws BadPositionCategoryException { 155 synchronized (getLockObject()) { 156 return super.getPositions(category); 157 } 158 } 159 } 160 | Popular Tags |