Search in sources :

Example 1 with IFollowElementAcceptor

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

the class CodetemplatesProposalProvider method createNestedProposals.

public void createNestedProposals(ContentAssistContext[] contexts, ITextViewer originalViewer, final ICompletionProposalAcceptor acceptor, TemplateData data) {
    for (ContentAssistContext context : contexts) {
        Builder builder = context.copy();
        builder.setViewer(originalViewer);
        ContentAssistContext myContext = builder.toContext();
        IFollowElementAcceptor selector = createNestedSelector(myContext, acceptor, data);
        for (AbstractElement element : myContext.getFirstSetGrammarElements()) {
            selector.accept(element);
        }
    }
}
Also used : AbstractElement(org.eclipse.xtext.AbstractElement) ContentAssistContext(org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext) Builder(org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext.Builder) IFollowElementAcceptor(org.eclipse.xtext.ui.editor.contentassist.IFollowElementAcceptor)

Example 2 with IFollowElementAcceptor

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

the class DefaultTemplateProposalProvider method getContextTypes.

@Override
protected TemplateContextType[] getContextTypes(final ContentAssistContext context) {
    final Set<TemplateContextType> result = Sets.newLinkedHashSet();
    IFollowElementAcceptor acceptor = createFollowElementAcceptor(result);
    List<AbstractElement> grammarElements = context.getFirstSetGrammarElements();
    for (AbstractElement element : grammarElements) acceptor.accept(element);
    return result.toArray(new TemplateContextType[result.size()]);
}
Also used : AbstractElement(org.eclipse.xtext.AbstractElement) IFollowElementAcceptor(org.eclipse.xtext.ui.editor.contentassist.IFollowElementAcceptor) TemplateContextType(org.eclipse.jface.text.templates.TemplateContextType)

Aggregations

AbstractElement (org.eclipse.xtext.AbstractElement)2 IFollowElementAcceptor (org.eclipse.xtext.ui.editor.contentassist.IFollowElementAcceptor)2 TemplateContextType (org.eclipse.jface.text.templates.TemplateContextType)1 ContentAssistContext (org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext)1 Builder (org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext.Builder)1