Search in sources :

Example 1 with ErlStringContentAssistProcessor

use of org.erlide.ui.editors.erl.completion.ErlStringContentAssistProcessor 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;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) ErlContentAssistProcessor(org.erlide.ui.editors.erl.completion.ErlContentAssistProcessor) IErlModule(org.erlide.engine.model.root.IErlModule) ErlStringContentAssistProcessor(org.erlide.ui.editors.erl.completion.ErlStringContentAssistProcessor) IContentAssistant(org.eclipse.jface.text.contentassist.IContentAssistant) ContentAssistant(org.eclipse.jface.text.contentassist.ContentAssistant)

Example 2 with ErlStringContentAssistProcessor

use of org.erlide.ui.editors.erl.completion.ErlStringContentAssistProcessor 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);
}
Also used : IContentAssistProcessor(org.eclipse.jface.text.contentassist.IContentAssistProcessor) ErlStringContentAssistProcessor(org.erlide.ui.editors.erl.completion.ErlStringContentAssistProcessor) Functions(org.eclipse.xtext.xbase.lib.Functions) ErlContentAssistProcessor(org.erlide.ui.editors.erl.completion.ErlContentAssistProcessor) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) IErlModule(org.erlide.engine.model.root.IErlModule) IDocument(org.eclipse.jface.text.IDocument)

Aggregations

IErlModule (org.erlide.engine.model.root.IErlModule)2 ErlContentAssistProcessor (org.erlide.ui.editors.erl.completion.ErlContentAssistProcessor)2 ErlStringContentAssistProcessor (org.erlide.ui.editors.erl.completion.ErlStringContentAssistProcessor)2 IDocument (org.eclipse.jface.text.IDocument)1 ContentAssistant (org.eclipse.jface.text.contentassist.ContentAssistant)1 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)1 IContentAssistProcessor (org.eclipse.jface.text.contentassist.IContentAssistProcessor)1 IContentAssistant (org.eclipse.jface.text.contentassist.IContentAssistant)1 Functions (org.eclipse.xtext.xbase.lib.Functions)1 IErlProject (org.erlide.engine.model.root.IErlProject)1