Chromium Code Reviews| Index: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/SemanticHighlightingManager_NEW.java |
| diff --git a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/SemanticHighlightingManager_NEW.java b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/SemanticHighlightingManager_NEW.java |
| index 9a66fd1d0ca4a63294b7ece482b77aa6a58d9679..996da72e7768a12384b3dc3398d2353316738ed3 100644 |
| --- a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/SemanticHighlightingManager_NEW.java |
| +++ b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/SemanticHighlightingManager_NEW.java |
| @@ -33,6 +33,7 @@ import org.eclipse.jface.text.DocumentEvent; |
| import org.eclipse.jface.text.IDocument; |
| import org.eclipse.jface.text.IPositionUpdater; |
| import org.eclipse.jface.text.IRegion; |
| +import org.eclipse.jface.text.ISynchronizable; |
| import org.eclipse.jface.text.ITextPresentationListener; |
| import org.eclipse.jface.text.Position; |
| import org.eclipse.jface.text.TextPresentation; |
| @@ -335,11 +336,26 @@ public class SemanticHighlightingManager_NEW implements AnalysisServerHighlights |
| HighlightRegion highlight = highlights[i]; |
| newPositions[i] = new HighlightPosition(highlight); |
| } |
| - synchronized (positionsLock) { |
| - lastText = document.get(); |
| - lastRegions = highlights; |
| - positions = newPositions; |
| + synchronized (getDocumentLockObject()) { |
|
Paul Berry
2015/01/28 18:30:22
It would be nice to have a comment here explaining
scheglov
2015/01/28 18:33:41
Done.
|
| + synchronized (positionsLock) { |
| + lastText = document.get(); |
| + lastRegions = highlights; |
| + positions = newPositions; |
| + } |
| + } |
| + } |
| + |
| + /** |
| + * Returns the lock to use to synchronize {@link #document} access. |
| + */ |
| + private Object getDocumentLockObject() { |
| + if (document instanceof ISynchronizable) { |
| + Object lock = ((ISynchronizable) document).getLockObject(); |
| + if (lock != null) { |
| + return lock; |
| + } |
| } |
| + return document; |
| } |
| /** |