use of org.eclipse.xtext.ui.editor.XtextSourceViewer in project xtext-eclipse by eclipse.
the class SpellingQuickfixTest method computeQuickAssistProposals.
protected ICompletionProposal[] computeQuickAssistProposals(int offset) {
XtextSourceViewer sourceViewer = getSourceViewer();
XtextReconciler reconciler = (XtextReconciler) sourceViewer.getAdapter(IReconciler.class);
IReconcilingStrategyExtension reconcilingStrategyExtension = (IReconcilingStrategyExtension) reconciler.getReconcilingStrategy("");
reconcilingStrategyExtension.initialReconcile();
QuickAssistAssistant quickAssistAssistant = (QuickAssistAssistant) sourceViewer.getQuickAssistAssistant();
IQuickAssistProcessor quickAssistProcessor = quickAssistAssistant.getQuickAssistProcessor();
ICompletionProposal[] quickAssistProposals = quickAssistProcessor.computeQuickAssistProposals(new TextInvocationContext(sourceViewer, offset, -1));
return quickAssistProposals;
}
use of org.eclipse.xtext.ui.editor.XtextSourceViewer in project xtext-eclipse by eclipse.
the class DirtyStateEditorSupportIntegrationTest method testUndoRedo.
/**
* @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=354123
*/
@Test
public void testUndoRedo() {
this.pushKey((IterableExtensions.<Character>head(((Iterable<Character>) Conversions.doWrapArray("a".toCharArray())))).charValue(), 0);
Assert.assertEquals(1, this.events.size());
Assert.assertEquals("fooa", IterableExtensions.<String>last(IterableExtensions.<IEObjectDescription>head(IterableExtensions.<IResourceDescription.Delta>head(IterableExtensions.<IResourceDescription.Event>last(this.events).getDeltas()).getNew().getExportedObjects()).getQualifiedName().getSegments()));
ISourceViewer _internalSourceViewer = this.editor.getInternalSourceViewer();
final IUndoManager undoManager = ((XtextSourceViewer) _internalSourceViewer).getUndoManager();
undoManager.undo();
NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
this.syncUtil.yieldToQueuedDisplayJobs(_nullProgressMonitor);
this.syncUtil.waitForReconciler(this.editor);
Assert.assertEquals(2, this.events.size());
Assert.assertNull(IterableExtensions.<IResourceDescription.Delta>head(IterableExtensions.<IResourceDescription.Event>last(this.events).getDeltas()).getNew());
undoManager.redo();
NullProgressMonitor _nullProgressMonitor_1 = new NullProgressMonitor();
this.syncUtil.yieldToQueuedDisplayJobs(_nullProgressMonitor_1);
this.syncUtil.waitForReconciler(this.editor);
Assert.assertEquals(3, this.events.size());
Assert.assertEquals("fooa", IterableExtensions.<String>last(IterableExtensions.<IEObjectDescription>head(IterableExtensions.<IResourceDescription.Delta>head(IterableExtensions.<IResourceDescription.Event>last(this.events).getDeltas()).getNew().getExportedObjects()).getQualifiedName().getSegments()));
}
use of org.eclipse.xtext.ui.editor.XtextSourceViewer in project xtext-eclipse by eclipse.
the class AbstractQuickfixTest method computeQuickAssistProposals.
protected ICompletionProposal[] computeQuickAssistProposals(XtextEditor editor, int offset) {
IResourcesSetupUtil.waitForBuild();
XtextSourceViewer sourceViewer = (XtextSourceViewer) editor.getInternalSourceViewer();
QuickAssistAssistant quickAssistAssistant = (QuickAssistAssistant) sourceViewer.getQuickAssistAssistant();
IQuickAssistProcessor quickAssistProcessor = quickAssistAssistant.getQuickAssistProcessor();
ICompletionProposal[] quickAssistProposals = quickAssistProcessor.computeQuickAssistProposals(new TextInvocationContext(sourceViewer, offset, -1));
return quickAssistProposals;
}
use of org.eclipse.xtext.ui.editor.XtextSourceViewer in project xtext-eclipse by eclipse.
the class HighlightingReconciler method refresh.
/**
* Refreshes the highlighting.
*/
public void refresh() {
if (oldCalculator != null || newCalculator != null) {
new Job("calculating highlighting") {
@Override
protected IStatus run(IProgressMonitor monitor) {
XtextSourceViewer mySourceViewer = sourceViewer;
if (mySourceViewer != null) {
IXtextDocument document = (IXtextDocument) mySourceViewer.getDocument();
if (document != null) {
document.readOnly(new CancelableUnitOfWork<Void, XtextResource>() {
@Override
public java.lang.Void exec(XtextResource state, CancelIndicator cancelIndicator) throws Exception {
beforeRefresh(state, cancelIndicator);
modelChanged(state, cancelIndicator);
return null;
}
});
}
}
return Status.OK_STATUS;
}
}.schedule();
} else {
Display display = getDisplay();
display.asyncExec(presenter.createSimpleUpdateRunnable());
}
}
use of org.eclipse.xtext.ui.editor.XtextSourceViewer in project n4js by eclipse.
the class InvalidatingHighlightingHelper method propertyChange.
@Override
public void propertyChange(PropertyChangeEvent event) {
super.propertyChange(event);
XtextEditor editor = myEditor;
XtextSourceViewer sourceViewer = mySourceViewer;
if (editor instanceof N4JSEditor && sourceViewer != null && event.getProperty().contains(".syntaxColorer.tokenStyles")) {
((N4JSEditor) editor).initializeViewerColors(sourceViewer);
sourceViewer.invalidateTextPresentation();
}
}
Aggregations