Skip to content

Commit 82ccd1e

Browse files
- Removed dead code in AnnotationModel.cleanup because mapLock can't be
null. - Added new javadoc to IAnnotationMap.getLockObject() - added assert.isLegal check to AnnotationMAp.setLockObject()
1 parent 080a1c7 commit 82ccd1e

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

bundles/org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationMap.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import java.util.Map;
2222
import java.util.Set;
2323

24+
import org.eclipse.core.runtime.Assert;
25+
2426
import org.eclipse.jface.text.Position;
2527

2628

@@ -56,6 +58,7 @@ public AnnotationMap(int capacity) {
5658

5759
@Override
5860
public synchronized void setLockObject(Object lockObject) {
61+
Assert.isLegal(fLockObject == null || fLockObject == lockObject, "Lock was already set"); //$NON-NLS-1$
5962
fLockObject= lockObject;
6063
}
6164

bundles/org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationModel.java

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -661,23 +661,12 @@ private void cleanup(boolean fireModelChanged, boolean forkNotification) {
661661
IAnnotationMap annotations= getAnnotationMap();
662662
Object mapLock = annotations.getLockObject();
663663

664-
if (mapLock == null) {
665-
Iterator<Annotation> e= annotations.keySetIterator();
666-
while (e.hasNext()) {
667-
Annotation a= e.next();
668-
Position p= annotations.get(a);
664+
synchronized (mapLock) {
665+
annotations.forEach((a, p) -> {
669666
if (p == null || p.isDeleted()) {
670667
deleted.add(a);
671668
}
672-
}
673-
} else {
674-
synchronized (mapLock) {
675-
annotations.forEach((a, p) -> {
676-
if (p == null || p.isDeleted()) {
677-
deleted.add(a);
678-
}
679-
});
680-
}
669+
});
681670
}
682671

683672
if (fireModelChanged && forkNotification) {

bundles/org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationMap.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,12 @@ public interface IAnnotationMap extends Map<Annotation, Position>, ISynchronizab
7979
*/
8080
@Override
8181
Collection<Position> values();
82+
83+
/**
84+
* {@inheritDoc}
85+
* Implementers of this interface should <b>never</b> return null.
86+
* @return <b>never</b> returns null
87+
*/
88+
@Override
89+
Object getLockObject();
8290
}

0 commit comments

Comments
 (0)