Search in sources :

Example 1 with DirtyRegionProcessor

use of org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor in project webtools.sourceediting by eclipse.

the class StructuredTextEditor method handleElementContentReplaced.

protected void handleElementContentReplaced() {
    super.handleElementContentReplaced();
    // queue a full revalidation of content
    IDocument document = getDocumentProvider().getDocument(getEditorInput());
    SourceViewerConfiguration sourceViewerConfiguration = getSourceViewerConfiguration();
    if (document != null && sourceViewerConfiguration != null && sourceViewerConfiguration.getReconciler(getSourceViewer()) instanceof DirtyRegionProcessor) {
        ((DirtyRegionProcessor) sourceViewerConfiguration.getReconciler(getSourceViewer())).processDirtyRegion(new DirtyRegion(0, document.getLength(), DirtyRegion.INSERT, document.get()));
    }
    /*
		 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=129906 - update
		 * selection to listeners
		 */
    ISelectionProvider selectionProvider = getSelectionProvider();
    ISelection originalSelection = selectionProvider.getSelection();
    if (selectionProvider instanceof StructuredSelectionProvider && originalSelection instanceof ITextSelection) {
        ITextSelection textSelection = (ITextSelection) originalSelection;
        // make sure the old selection is actually still valid
        if (!textSelection.isEmpty() && (document == null || textSelection.getOffset() + textSelection.getLength() <= document.getLength())) {
            SelectionChangedEvent syntheticEvent = new SelectionChangedEvent(selectionProvider, new TextSelection(textSelection.getOffset(), textSelection.getLength()));
            ((StructuredSelectionProvider) selectionProvider).handleSelectionChanged(syntheticEvent);
            ((StructuredSelectionProvider) selectionProvider).handlePostSelectionChanged(syntheticEvent);
        } else {
            SelectionChangedEvent syntheticEvent = new SelectionChangedEvent(selectionProvider, new TextSelection(0, 0));
            ((StructuredSelectionProvider) selectionProvider).handleSelectionChanged(syntheticEvent);
            ((StructuredSelectionProvider) selectionProvider).handlePostSelectionChanged(syntheticEvent);
        }
    }
}
Also used : SourceViewerConfiguration(org.eclipse.jface.text.source.SourceViewerConfiguration) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ITextSelection(org.eclipse.jface.text.ITextSelection) TextSelection(org.eclipse.jface.text.TextSelection) IBlockTextSelection(org.eclipse.jface.text.IBlockTextSelection) ISelection(org.eclipse.jface.viewers.ISelection) DirtyRegion(org.eclipse.jface.text.reconciler.DirtyRegion) DirtyRegionProcessor(org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IDocument(org.eclipse.jface.text.IDocument) ITextSelection(org.eclipse.jface.text.ITextSelection)

Aggregations

IBlockTextSelection (org.eclipse.jface.text.IBlockTextSelection)1 IDocument (org.eclipse.jface.text.IDocument)1 ITextSelection (org.eclipse.jface.text.ITextSelection)1 TextSelection (org.eclipse.jface.text.TextSelection)1 DirtyRegion (org.eclipse.jface.text.reconciler.DirtyRegion)1 SourceViewerConfiguration (org.eclipse.jface.text.source.SourceViewerConfiguration)1 ISelection (org.eclipse.jface.viewers.ISelection)1 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 DirtyRegionProcessor (org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor)1