use of org.erlide.ui.editors.erl.completion.ErlContentAssistProcessor in project erlide_eclipse by erlang.
the class ErlangSourceViewerConfiguration method getContentAssistant.
@Override
public IContentAssistant getContentAssistant(final ISourceViewer sourceViewer) {
final ContentAssistant contentAssistant = new ContentAssistant();
contentAssistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
final IErlModule module = getModule();
final IErlProject project = getProject();
contentAssistProcessor = new ErlContentAssistProcessor(sourceViewer, module, project, contentAssistant);
contentAssistProcessorForStrings = new ErlStringContentAssistProcessor(sourceViewer, module, project, contentAssistant);
contentAssistProcessor.setToPrefs();
contentAssistant.setContentAssistProcessor(contentAssistProcessor, IDocument.DEFAULT_CONTENT_TYPE);
contentAssistant.setContentAssistProcessor(contentAssistProcessor, IErlangPartitions.ERLANG_QATOM);
contentAssistant.setContentAssistProcessor(contentAssistProcessorForStrings, IErlangPartitions.ERLANG_STRING);
contentAssistant.enableAutoInsert(true);
contentAssistant.enablePrefixCompletion(false);
contentAssistant.setDocumentPartitioning(IErlangPartitions.ERLANG_PARTITIONING);
contentAssistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
contentAssistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
return contentAssistant;
}
use of org.erlide.ui.editors.erl.completion.ErlContentAssistProcessor in project erlide_eclipse by erlang.
the class ContentAssistTest method completionTest.
public void completionTest(final IErlProject project, final String name, final String text, final int offset, final List<String> expected, final boolean inStrings) throws CoreException {
final IDocument document = new StringDocument(text);
final IErlModule module = ErlideTestUtils.createModule(project, name, text);
module.open(null);
final MockSourceViewer sourceViewer = new MockSourceViewer(document, offset);
final IContentAssistProcessor p = inStrings ? new ErlStringContentAssistProcessor(sourceViewer, module, project, null) : new ErlContentAssistProcessor(sourceViewer, module, project, null);
final ICompletionProposal[] completionProposals = p.computeCompletionProposals(sourceViewer, offset);
assertThat(ListExtensions.map(Lists.newArrayList(completionProposals), new Functions.Function1<ICompletionProposal, String>() {
@Override
public String apply(final ICompletionProposal cp) {
return cp.getDisplayString();
}
})).isEqualTo(expected);
}
Aggregations