Java Code Examples for org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext#getFirstSetGrammarElements()

The following examples show how to use org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext#getFirstSetGrammarElements() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CodetemplatesProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
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);
		}
	}
}
 
Example 2
Source File: ParserBasedContentAssistContextFactory.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected boolean isLikelyToBeValidProposal(INode lastCompleteNode, Iterable<ContentAssistContext> contexts) {
	for(ContentAssistContext context: contexts) {
		for (AbstractElement element: context.getFirstSetGrammarElements()) {
			if (element instanceof Keyword) {
				String keywordValue = ((Keyword) element).getValue();
				String lastText = ((ILeafNode) lastCompleteNode).getText();
				if (keywordValue.equals(lastText)) 
					return true;
			}
		}
	}
	return false;
}
 
Example 3
Source File: DefaultTemplateProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@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()]);
}