Search in sources :

Example 6 with ICompletionProposalExtension

use of org.eclipse.jface.text.contentassist.ICompletionProposalExtension in project xtext-eclipse by eclipse.

the class ContentAssistProcessorTestBuilder method appendAndApplyProposal.

protected ContentAssistProcessorTestBuilder appendAndApplyProposal(ICompletionProposal proposal, ISourceViewer sourceViewer, String model, int position) throws Exception {
    IDocument document = sourceViewer.getDocument();
    int offset = position;
    if (model != null) {
        document.set(getModel() + model);
        offset += model.length();
    }
    if (proposal instanceof ICompletionProposalExtension2) {
        ICompletionProposalExtension2 proposalExtension2 = (ICompletionProposalExtension2) proposal;
        proposalExtension2.apply(sourceViewer, (char) 0, SWT.NONE, offset);
    } else if (proposal instanceof ICompletionProposalExtension) {
        ICompletionProposalExtension proposalExtension = (ICompletionProposalExtension) proposal;
        proposalExtension.apply(document, (char) 0, offset);
    } else {
        proposal.apply(document);
    }
    return reset().append(document.get());
}
Also used : ICompletionProposalExtension(org.eclipse.jface.text.contentassist.ICompletionProposalExtension) ICompletionProposalExtension2(org.eclipse.jface.text.contentassist.ICompletionProposalExtension2) IDocument(org.eclipse.jface.text.IDocument)

Aggregations

ICompletionProposalExtension (org.eclipse.jface.text.contentassist.ICompletionProposalExtension)6 IDocument (org.eclipse.jface.text.IDocument)5 ICompletionProposalExtension2 (org.eclipse.jface.text.contentassist.ICompletionProposalExtension2)5 Point (org.eclipse.swt.graphics.Point)4 IRewriteTarget (org.eclipse.jface.text.IRewriteTarget)2 ITextViewerExtension (org.eclipse.jface.text.ITextViewerExtension)2 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)2 ArrayList (java.util.ArrayList)1 IEditingSupportRegistry (org.eclipse.jface.text.IEditingSupportRegistry)1 IContextInformation (org.eclipse.jface.text.contentassist.IContextInformation)1