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);
}
}
}
Aggregations