Java Code Examples for org.eclipse.xtext.parser.antlr.IUnorderedGroupHelper#select()

The following examples show how to use org.eclipse.xtext.parser.antlr.IUnorderedGroupHelper#select() . 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: CustomN4JSParser.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
private AbstractInternalContentAssistParser createParser(AbstractElement parseMe, FollowElement baseFollowElement) {
	AbstractInternalContentAssistParser parser = createParser();
	parser.setUnorderedGroupHelper(getUnorderedGroupHelper().get());
	parser.getUnorderedGroupHelper().initializeWith(parser);
	ObservableXtextTokenStream tokens = toTokenStream(baseFollowElement, parser);
	parser.setTokenStream(tokens);
	tokens.setListener(parser);
	parser.getGrammarElements().addAll(baseFollowElement.getTrace());
	parser.getGrammarElements().add(parseMe);
	parser.getLocalTrace().addAll(baseFollowElement.getLocalTrace());
	parser.getLocalTrace().add(parseMe);
	parser.getParamStack().addAll(baseFollowElement.getParamStack());
	if (parseMe instanceof UnorderedGroup && baseFollowElement.getGrammarElement() == parseMe) {
		UnorderedGroup group = (UnorderedGroup) parseMe;
		final IUnorderedGroupHelper helper = parser.getUnorderedGroupHelper();
		helper.enter(group);
		for (AbstractElement consumed : baseFollowElement.getHandledUnorderedGroupElements()) {
			parser.before(consumed);
			helper.select(group, group.getElements().indexOf(consumed));
			helper.returnFromSelection(group);
			parser.after(consumed);
		}
		parser.setUnorderedGroupHelper(wrap(helper));
	}
	return parser;
}
 
Example 2
Source File: BaseContentAssistParser.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.14
 */
protected IUnorderedGroupHelper getInitializedUnorderedGroupHelper(FE element, InternalParser parser,
		UnorderedGroup group) {
	final IUnorderedGroupHelper helper = parser.getUnorderedGroupHelper();
	helper.enter(group);
	for (AbstractElement consumed : element.getHandledUnorderedGroupElements()) {
		parser.before(consumed);
		helper.select(group, group.getElements().indexOf(consumed));
		helper.returnFromSelection(group);
		parser.after(consumed);
	}
	return helper;
}