Search in sources :

Example 1 with XtextSourceViewer

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;
}
Also used : IQuickAssistProcessor(org.eclipse.jface.text.quickassist.IQuickAssistProcessor) XtextReconciler(org.eclipse.xtext.ui.editor.reconciler.XtextReconciler) XtextSourceViewer(org.eclipse.xtext.ui.editor.XtextSourceViewer) IReconciler(org.eclipse.jface.text.reconciler.IReconciler) TextInvocationContext(org.eclipse.jface.text.source.TextInvocationContext) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) QuickAssistAssistant(org.eclipse.jface.text.quickassist.QuickAssistAssistant) IReconcilingStrategyExtension(org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension)

Example 2 with XtextSourceViewer

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()));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) XtextSourceViewer(org.eclipse.xtext.ui.editor.XtextSourceViewer) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) IUndoManager(org.eclipse.jface.text.IUndoManager) Event(org.eclipse.swt.widgets.Event) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) AbstractEditorTest(org.eclipse.xtext.ui.testing.AbstractEditorTest) Test(org.junit.Test)

Example 3 with XtextSourceViewer

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;
}
Also used : IQuickAssistProcessor(org.eclipse.jface.text.quickassist.IQuickAssistProcessor) XtextSourceViewer(org.eclipse.xtext.ui.editor.XtextSourceViewer) TextInvocationContext(org.eclipse.jface.text.source.TextInvocationContext) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) QuickAssistAssistant(org.eclipse.jface.text.quickassist.QuickAssistAssistant)

Example 4 with XtextSourceViewer

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());
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) XtextSourceViewer(org.eclipse.xtext.ui.editor.XtextSourceViewer) CancelableUnitOfWork(org.eclipse.xtext.util.concurrent.CancelableUnitOfWork) XtextResource(org.eclipse.xtext.resource.XtextResource) CancelIndicator(org.eclipse.xtext.util.CancelIndicator) Job(org.eclipse.core.runtime.jobs.Job) IXtextDocument(org.eclipse.xtext.ui.editor.model.IXtextDocument) Display(org.eclipse.swt.widgets.Display)

Example 5 with XtextSourceViewer

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();
    }
}
Also used : XtextSourceViewer(org.eclipse.xtext.ui.editor.XtextSourceViewer) XtextEditor(org.eclipse.xtext.ui.editor.XtextEditor) N4JSEditor(org.eclipse.n4js.ui.N4JSEditor)

Aggregations

XtextSourceViewer (org.eclipse.xtext.ui.editor.XtextSourceViewer)6 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)2 IQuickAssistProcessor (org.eclipse.jface.text.quickassist.IQuickAssistProcessor)2 QuickAssistAssistant (org.eclipse.jface.text.quickassist.QuickAssistAssistant)2 TextInvocationContext (org.eclipse.jface.text.source.TextInvocationContext)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Job (org.eclipse.core.runtime.jobs.Job)1 IUndoManager (org.eclipse.jface.text.IUndoManager)1 IReconciler (org.eclipse.jface.text.reconciler.IReconciler)1 IReconcilingStrategyExtension (org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension)1 AnnotationModel (org.eclipse.jface.text.source.AnnotationModel)1 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)1 N4JSEditor (org.eclipse.n4js.ui.N4JSEditor)1 Display (org.eclipse.swt.widgets.Display)1 Event (org.eclipse.swt.widgets.Event)1 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)1 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)1 XtextResource (org.eclipse.xtext.resource.XtextResource)1