Search in sources :

Example 1 with CompletionProposalComputer

use of org.eclipse.xtext.ui.editor.contentassist.CompletionProposalComputer in project dsl-devkit by dsldevkit.

the class AbstractContentAssistUiTest method createCompletionProposalComputer.

/**
 * Helper function to find the correct CompletionProposalComputer for the given offset.
 *
 * @param offset
 *          offset in test file
 * @return language and offset specific content assist proposal computer
 */
private CompletionProposalComputer createCompletionProposalComputer(final int offset) {
    XtextSourceViewerConfiguration configuration = getEditor().getXtextSourceViewerConfiguration();
    IContentAssistant contentAssistant = configuration.getContentAssistant(getViewer());
    IContentAssistProcessor contentAssistProcessor;
    try {
        contentAssistProcessor = contentAssistant.getContentAssistProcessor(getDocument().getContentType(offset));
    } catch (BadLocationException e) {
        contentAssistProcessor = getTestUtil().get(IContentAssistProcessor.class);
    }
    if (contentAssistProcessor == null) {
        contentAssistProcessor = getTestUtil().get(IContentAssistProcessor.class);
    }
    return new CompletionProposalComputer((State) contentAssistProcessor, (ITextViewer) getViewer(), offset);
}
Also used : CompletionProposalComputer(org.eclipse.xtext.ui.editor.contentassist.CompletionProposalComputer) IContentAssistant(org.eclipse.jface.text.contentassist.IContentAssistant) IContentAssistProcessor(org.eclipse.jface.text.contentassist.IContentAssistProcessor) BadLocationException(org.eclipse.jface.text.BadLocationException) XtextSourceViewerConfiguration(org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration)

Aggregations

BadLocationException (org.eclipse.jface.text.BadLocationException)1 IContentAssistProcessor (org.eclipse.jface.text.contentassist.IContentAssistProcessor)1 IContentAssistant (org.eclipse.jface.text.contentassist.IContentAssistant)1 XtextSourceViewerConfiguration (org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration)1 CompletionProposalComputer (org.eclipse.xtext.ui.editor.contentassist.CompletionProposalComputer)1