use of org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration in project xtext-eclipse by eclipse.
the class ContentAssistProcessorTestBuilder method appendAndApplyProposal.
public ContentAssistProcessorTestBuilder appendAndApplyProposal(String model, int position, String proposalString) throws Exception {
IXtextDocument document = getDocument(getModel());
Shell shell = new Shell();
try {
XtextSourceViewerConfiguration configuration = get(XtextSourceViewerConfiguration.class);
ISourceViewer sourceViewer = getSourceViewer(shell, document, configuration);
ICompletionProposal[] proposals = computeCompletionProposals(document, position, shell);
ICompletionProposal proposal = findProposal(proposalString, proposals);
return appendAndApplyProposal(proposal, sourceViewer, model, position);
} finally {
shell.dispose();
}
}
use of org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration in project xtext-eclipse by eclipse.
the class ContentAssistProcessorTestBuilder method computeCompletionProposals.
protected ICompletionProposal[] computeCompletionProposals(final IXtextDocument xtextDocument, int cursorPosition, Shell shell) throws BadLocationException {
XtextSourceViewerConfiguration configuration = get(XtextSourceViewerConfiguration.class);
ISourceViewer sourceViewer = getSourceViewer(shell, xtextDocument, configuration);
return computeCompletionProposals(xtextDocument, cursorPosition, configuration, sourceViewer);
}
use of org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration in project xtext-eclipse by eclipse.
the class ContentAssistProcessorTestBuilder method appendAndApplyProposal.
public ContentAssistProcessorTestBuilder appendAndApplyProposal(String model, int position, String proposalString) throws Exception {
IXtextDocument document = getDocument(getModel());
Shell shell = new Shell();
try {
XtextSourceViewerConfiguration configuration = get(XtextSourceViewerConfiguration.class);
ISourceViewer sourceViewer = getSourceViewer(shell, document, configuration);
ICompletionProposal[] proposals = computeCompletionProposals(document, position, shell);
ICompletionProposal proposal = findProposal(proposalString, proposals);
return appendAndApplyProposal(proposal, sourceViewer, model, position);
} finally {
shell.dispose();
}
}
use of org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration 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);
}
use of org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration in project xtext-eclipse by eclipse.
the class ContentAssistProcessorTestBuilder method applyProposal.
protected ContentAssistProcessorTestBuilder applyProposal(ICompletionProposal proposal, int position, IXtextDocument document) throws Exception {
Shell shell = new Shell();
try {
XtextSourceViewerConfiguration configuration = get(XtextSourceViewerConfiguration.class);
ISourceViewer sourceViewer = getSourceViewer(shell, document, configuration);
return appendAndApplyProposal(proposal, sourceViewer, model, position);
} finally {
shell.dispose();
}
}
Aggregations