org.eclipse.xtext.ide.editor.contentassist.antlr.internal.AbstractInternalContentAssistParser Java Examples

The following examples show how to use org.eclipse.xtext.ide.editor.contentassist.antlr.internal.AbstractInternalContentAssistParser. 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: PartialFileAwareTestLanguageContentAssistParser.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #3
Source File: PartialRegularExpressionContentAssistParser.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #4
Source File: PartialXtendContentAssistParser.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #5
Source File: PartialTestLanguageContentAssistParser.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #6
Source File: PartialPartialContentAssistTestLanguageContentAssistParser.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #7
Source File: PartialRenameTestLanguageContentAssistParser.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #8
Source File: PartialIndentationAwareUiTestLanguageContentAssistParser.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #9
Source File: PartialPartialSerializationTestLanguageContentAssistParser.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #10
Source File: PartialXtextContentAssistParser.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #11
Source File: PartialCodetemplatesContentAssistParser.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #12
Source File: PartialXtextGrammarTestLanguageContentAssistParser.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #13
Source File: PartialNoJdtTestLanguageContentAssistParser.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #14
Source File: PartialNestedRefsTestLanguageContentAssistParser.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #15
Source File: PartialHelloWorldContentAssistParser.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #16
Source File: EntryRuleContentAssistParser.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (entryRule == null)
		return super.getFollowElements(parser);
	try {
		Method method = parser.getClass().getMethod(ENTRY_RULE + entryRule);
		method.invoke(parser);
		return parser.getFollowElements();
	} catch (Exception ex) {
		throw new RuntimeException(ex);
	}
}
 
Example #17
Source File: PartialGamlContentAssistParser.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #18
Source File: PartialSARLContentAssistParser.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #19
Source File: PartialArithmeticsContentAssistParser.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #20
Source File: PartialN4JSContentAssistParser.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #21
Source File: CustomN4JSParser.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Workaround for Xpect which messes with the injectors and singletons.
 *
 * Rather than trying to find the rule name in the cached instance of ruleNames, we invoke the entry rule directly.
 */
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	try {
		InternalN4JSParser casted = (InternalN4JSParser) parser;
		casted.entryRuleScript();
		return casted.getFollowElements();
	} catch (RecognitionException e) {
		throw new RuntimeException(e);
	}
}
 
Example #22
Source File: CustomN4JSParser.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Initialize the parser properly with the given tokens and process it.
 */
private Collection<FollowElement> doGetFollowElements(
		AbstractInternalContentAssistParser parser,
		ObservableXtextTokenStream tokens,
		String ruleName) {
	tokens.setInitialHiddenTokens(getInitialHiddenTokens());
	parser.setTokenStream(tokens);
	IUnorderedGroupHelper helper = getUnorderedGroupHelper().get();
	parser.setUnorderedGroupHelper(helper);
	helper.initializeWith(parser);
	tokens.setListener(parser);
	Collection<FollowElement> followElements = getFollowElements(parser, ruleName);
	return followElements;
}
 
Example #23
Source File: CustomN4JSParser.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
private void collectFollowElements(AbstractElement parseMe, FollowElement baseFollowElement,
		Collection<FollowElement> result) {
	String ruleName = getRuleName(parseMe);
	String[][] allRuleNames = getRequiredRuleNames(ruleName, baseFollowElement.getParamStack(),
			parseMe);
	for (String[] ruleNames : allRuleNames) {
		for (int i = 0; i < ruleNames.length; i++) {
			AbstractInternalContentAssistParser parser = createParser(parseMe, baseFollowElement);
			Collection<FollowElement> elements = getFollowElements(parser, parseMe, ruleNames, i);
			result.addAll(elements);
		}
	}
}
 
Example #24
Source File: PartialJSONContentAssistParser.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #25
Source File: PartialTypesContentAssistParser.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #26
Source File: PartialBromiumContentAssistParser.java    From bromium with MIT License 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #27
Source File: PartialPureXbaseContentAssistParser.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #28
Source File: PartialMyDslContentAssistParser.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #29
Source File: PartialXmlContentAssistParser.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}
 
Example #30
Source File: PartialEcore2XtextTestContentAssistParser.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
	if (rule == null || rule.eIsProxy())
		return Collections.emptyList();
	String methodName = "entryRule" + rule.getName();
	PolymorphicDispatcher<Collection<FollowElement>> dispatcher = 
		new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
	dispatcher.invoke();
	return parser.getFollowElements();
}