diff options
author | Dani Megert | 2008-07-31 14:54:12 +0000 |
---|---|---|
committer | Dani Megert | 2008-07-31 14:54:12 +0000 |
commit | a81b084e058637fafc0ae428f3100fd99c93d7d5 (patch) | |
tree | 4bd0c3527de8d4b6a544c02767ed75c7a3073b31 /org.eclipse.jface.text/projection | |
parent | cdd15515009114f60f47343d8be9df2bc6980f2c (diff) | |
download | eclipse.platform.text-a81b084e058637fafc0ae428f3100fd99c93d7d5.tar.gz eclipse.platform.text-a81b084e058637fafc0ae428f3100fd99c93d7d5.tar.xz eclipse.platform.text-a81b084e058637fafc0ae428f3100fd99c93d7d5.zip |
Fixed bug 190810: [projection] Format operation is slow on big file when Folding is enabled
Diffstat (limited to 'org.eclipse.jface.text/projection')
-rw-r--r-- | org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java index f91b3d6a69c..cc59187f513 100644 --- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java +++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java @@ -30,10 +30,14 @@ import org.eclipse.core.runtime.Assert; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DocumentEvent; +import org.eclipse.jface.text.DocumentRewriteSessionEvent; +import org.eclipse.jface.text.DocumentRewriteSessionType; import org.eclipse.jface.text.FindReplaceDocumentAdapter; import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IDocumentExtension4; import org.eclipse.jface.text.IDocumentInformationMappingExtension; import org.eclipse.jface.text.IDocumentListener; +import org.eclipse.jface.text.IDocumentRewriteSessionListener; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ISlaveDocumentManager; import org.eclipse.jface.text.ITextViewerExtension5; @@ -72,6 +76,8 @@ import org.eclipse.jface.text.source.SourceViewer; * @noextend This class is not intended to be subclassed by clients. */ public class ProjectionViewer extends SourceViewer implements ITextViewerExtension5 { + + private static final int BASE= INFORMATION; // see ISourceViewer.INFORMATION @@ -299,6 +305,23 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi * @since 3.1 */ private int fDeletedLines; + + /** + * The listener for document rewrite sessions. + * + * @since 3.5 + */ + private final IDocumentRewriteSessionListener fSessionListener= new IDocumentRewriteSessionListener() { + + public void documentRewriteSessionChanged(DocumentRewriteSessionEvent event) { + if (event.getSession().getSessionType() == DocumentRewriteSessionType.UNRESTRICTED_SMALL) + return; + if (DocumentRewriteSessionEvent.SESSION_START.equals(event.getChangeType())) + disableProjection(); + else if (DocumentRewriteSessionEvent.SESSION_STOP.equals(event.getChangeType())) + enableProjection(); + } + }; /** @@ -366,10 +389,23 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi fProjectionAnnotationModel= null; } + IDocument oldDocument= getDocument(); + if (oldDocument instanceof IDocumentExtension4) { + IDocumentExtension4 ext= (IDocumentExtension4)oldDocument; + ext.removeDocumentRewriteSessionListener(fSessionListener); + } + super.setDocument(document, annotationModel, modelRangeOffset, modelRangeLength); + if (document instanceof IDocumentExtension4) { + IDocumentExtension4 ext= (IDocumentExtension4)document; + ext.addDocumentRewriteSessionListener(fSessionListener); + } + if (wasProjectionEnabled && document != null) enableProjection(); + + } /* |