use of org.eclipse.xtext.ui.tests.editor.contentassist.tests.TwoParametersTestLanguageInjectorProvider in project xtext-eclipse by eclipse.
the class ParametersContentAssistParserSanityTest method methodNames.
/**
* Returns test data.
*/
@Parameters(name = "{0}")
public static Collection<Object[]> methodNames() {
try {
TwoParametersTestLanguageInjectorProvider injectorProvider = new TwoParametersTestLanguageInjectorProvider();
try {
injectorProvider.setupRegistry();
Injector injector = injectorProvider.getInjector();
DummyParser dummyParser = new DummyParser();
TwoParametersTestLanguageGrammarAccess grammarAccess = injector.getInstance(TwoParametersTestLanguageGrammarAccess.class);
RuleNames ruleNames = RuleNames.getRuleNames(grammarAccess.getGrammar(), false);
RuleFilter ruleFilter = new RuleFilter();
ruleFilter.setDiscardUnreachableRules(true);
FlattenedGrammarAccess flattened = new FlattenedGrammarAccess(ruleNames, ruleFilter);
Grammar flattenedGrammar = flattened.getFlattenedGrammar();
dummyParser.setGrammarAccess(grammarAccess);
dummyParser.setNameMappings(new TwoParametersTestLanguageParser.NameMappings(grammarAccess));
dummyParser.getRuleName(null);
Map<AbstractElement, String> nameMappings = new ReflectExtensions().get(dummyParser.getNameMappings(), "mappings");
List<String> methodNames = Lists.newArrayList(nameMappings.values());
Collections.sort(methodNames);
Set<String> flattenedRuleNames = Sets.newHashSet(Lists.transform(flattenedGrammar.getRules(), r -> r.getName()));
return Lists.transform(methodNames, (s) -> new Object[] { s, flattenedRuleNames });
} finally {
injectorProvider.restoreRegistry();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations