Search in sources :

Example 1 with ITemplateAcceptor

use of org.eclipse.xtext.ui.editor.contentassist.ITemplateAcceptor in project xtext-eclipse by eclipse.

the class AbstractTemplateProposalProvider method createTemplates.

@Override
public void createTemplates(ContentAssistContext context, ITemplateAcceptor acceptor) {
    if (!acceptor.canAcceptMoreTemplates())
        return;
    TemplateContext[] templateContexts = createTemplateContexts(context);
    if (templateContexts == null || templateContexts.length == 0)
        return;
    ITemplateAcceptor nullSafe = new NullSafeTemplateAcceptor(acceptor);
    for (TemplateContext templateContext : templateContexts) {
        if (!nullSafe.canAcceptMoreTemplates())
            return;
        // name of the selection variables {line, word}_selection //$NON-NLS-1$
        templateContext.setVariable("selection", context.getSelectedText());
        createTemplates(templateContext, context, nullSafe);
    }
}
Also used : ITemplateAcceptor(org.eclipse.xtext.ui.editor.contentassist.ITemplateAcceptor) TemplateContext(org.eclipse.jface.text.templates.TemplateContext)

Aggregations

TemplateContext (org.eclipse.jface.text.templates.TemplateContext)1 ITemplateAcceptor (org.eclipse.xtext.ui.editor.contentassist.ITemplateAcceptor)1