Search in sources :

Example 1 with TextInvocationContext

use of org.eclipse.jface.text.source.TextInvocationContext 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 TextInvocationContext

use of org.eclipse.jface.text.source.TextInvocationContext 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 3 with TextInvocationContext

use of org.eclipse.jface.text.source.TextInvocationContext in project eclipse.platform.text by eclipse.

the class SpellingCorrectionProcessor method computeQuickAssistProposals.

/*
	 * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int)
	 */
@Override
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext quickAssistContext) {
    ISourceViewer viewer = quickAssistContext.getSourceViewer();
    int documentOffset = quickAssistContext.getOffset();
    int length = viewer != null ? viewer.getSelectedRange().y : -1;
    TextInvocationContext context = new TextInvocationContext(viewer, documentOffset, length);
    IAnnotationModel model = viewer.getAnnotationModel();
    if (model == null)
        return fgNoSuggestionsProposal;
    List<ICompletionProposal> proposals = computeProposals(context, model);
    if (proposals.isEmpty())
        return fgNoSuggestionsProposal;
    return proposals.toArray(new ICompletionProposal[proposals.size()]);
}
Also used : TextInvocationContext(org.eclipse.jface.text.source.TextInvocationContext) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer)

Aggregations

ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)3 TextInvocationContext (org.eclipse.jface.text.source.TextInvocationContext)3 IQuickAssistProcessor (org.eclipse.jface.text.quickassist.IQuickAssistProcessor)2 QuickAssistAssistant (org.eclipse.jface.text.quickassist.QuickAssistAssistant)2 XtextSourceViewer (org.eclipse.xtext.ui.editor.XtextSourceViewer)2 IReconciler (org.eclipse.jface.text.reconciler.IReconciler)1 IReconcilingStrategyExtension (org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension)1 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)1 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)1 XtextReconciler (org.eclipse.xtext.ui.editor.reconciler.XtextReconciler)1