Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundles/org.eclipse.core.filebuffers/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.core.filebuffers; singleton:=true
Bundle-Version: 3.8.300.qualifier
Bundle-Version: 3.8.400.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
*******************************************************************************/
package org.eclipse.core.internal.filebuffers;

import java.util.List;
import java.util.Map;

import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.BadPartitioningException;
import org.eclipse.jface.text.BadPositionCategoryException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.DocumentRewriteSession;
import org.eclipse.jface.text.DocumentRewriteSessionType;
import org.eclipse.jface.text.IDocumentExtension4;
Expand All @@ -38,6 +42,97 @@ public class SynchronizableDocument extends Document implements ISynchronizable

private Object fLockObject;

@Override
protected void updateDocumentStructures(DocumentEvent event) {
Object lockObject= getLockObject();
if (lockObject == null) {
super.updateDocumentStructures(event);
return;
}
synchronized (lockObject) {
super.updateDocumentStructures(event);
}
}

@Override
public void removePositionCategory(String category) throws BadPositionCategoryException {
Object lockObject= getLockObject();
if (lockObject == null) {
super.removePositionCategory(category);
return;
}
synchronized (lockObject) {
super.removePositionCategory(category);
}
}

@Override
public String[] getPositionCategories() {
Object lockObject= getLockObject();
if (lockObject == null) {
return super.getPositionCategories();
}
synchronized (lockObject) {
return super.getPositionCategories();
}
}

@Override
protected Map<String, List<Position>> getDocumentManagedPositions() {
Object lockObject= getLockObject();
if (lockObject == null) {
return super.getDocumentManagedPositions();
}
synchronized (lockObject) {
return super.getDocumentManagedPositions();
}
}

@Override
public boolean containsPositionCategory(String category) {
Object lockObject= getLockObject();
if (lockObject == null) {
return super.containsPositionCategory(category);
}
synchronized (lockObject) {
return super.containsPositionCategory(category);
}
}

@Override
public boolean containsPosition(String category, int offset, int length) {
Object lockObject= getLockObject();
if (lockObject == null) {
return super.containsPosition(category, offset, length);
}
synchronized (lockObject) {
return super.containsPosition(category, offset, length);
}
}

@Override
public int computeIndexInCategory(String category, int offset) throws BadLocationException, BadPositionCategoryException {
Object lockObject= getLockObject();
if (lockObject == null) {
return super.computeIndexInCategory(category, offset);
}
synchronized (lockObject) {
return super.computeIndexInCategory(category, offset);
}
}

@Override
public void addPositionCategory(String category) {
Object lockObject= getLockObject();
if (lockObject == null) {
super.addPositionCategory(category);
return;
}
synchronized (lockObject) {
super.addPositionCategory(category);
}
}

@Override
public synchronized void setLockObject(Object lockObject) {
fLockObject= lockObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,12 @@ public void addPosition(String category, Position position) throws BadLocationEx

List<Position> list= fPositions.get(category);
if (list == null)
throw new BadPositionCategoryException();
throw new BadPositionCategoryException(category);
list.add(computeIndexInPositionList(list, position.offset), position);

List<Position> endPositions= fEndPositions.get(category);
if (endPositions == null)
throw new BadPositionCategoryException();
throw new BadPositionCategoryException(category);
endPositions.add(computeIndexInPositionList(endPositions, position.offset + position.length - 1, false), position);
}

Expand Down Expand Up @@ -514,7 +514,7 @@ public int computeIndexInCategory(String category, int offset) throws BadLocatio

List<Position> c= fPositions.get(category);
if (c == null)
throw new BadPositionCategoryException();
throw new BadPositionCategoryException(category);

return computeIndexInPositionList(c, offset);
}
Expand Down Expand Up @@ -925,7 +925,7 @@ public Position[] getPositions(String category) throws BadPositionCategoryExcept

List<Position> c= fPositions.get(category);
if (c == null)
throw new BadPositionCategoryException();
throw new BadPositionCategoryException(category);

Position[] positions= new Position[c.size()];
c.toArray(positions);
Expand Down Expand Up @@ -980,12 +980,12 @@ public void removePosition(String category, Position position) throws BadPositio

List<Position> c= fPositions.get(category);
if (c == null)
throw new BadPositionCategoryException();
throw new BadPositionCategoryException(category);
removeFromPositionsList(c, position, true);

List<Position> endPositions= fEndPositions.get(category);
if (endPositions == null)
throw new BadPositionCategoryException();
throw new BadPositionCategoryException(category);
removeFromPositionsList(endPositions, position, false);
}

Expand Down Expand Up @@ -1043,7 +1043,7 @@ public void removePositionCategory(String category) throws BadPositionCategoryEx
return;

if ( !containsPositionCategory(category))
throw new BadPositionCategoryException();
throw new BadPositionCategoryException(category);

fPositions.remove(category);
fEndPositions.remove(category);
Expand Down Expand Up @@ -1674,7 +1674,7 @@ private List<Position> getStartingPositions(String category, int offset, int len
private List<Position> getEndingPositions(String category, int offset, int length) throws BadPositionCategoryException {
List<Position> positions= fEndPositions.get(category);
if (positions == null)
throw new BadPositionCategoryException();
throw new BadPositionCategoryException(category);

int indexStart= computeIndexInPositionList(positions, offset, false);
int indexEnd= computeIndexInPositionList(positions, offset + length, false);
Expand Down
Loading