use of org.eclipse.n4js.services.N4JSGrammarAccess in project n4js by eclipse.
the class ContentAssistParserSanityTest method methodNames.
/**
* Returns test data.
*/
@Parameters(name = "{0}")
public static Collection<Object[]> methodNames() {
try {
N4JSInjectorProvider injectorProvider = new N4JSInjectorProvider();
Injector injector = injectorProvider.getInjector();
DummyParser dummyParser = new DummyParser();
N4JSGrammarAccess grammarAccess = injector.getInstance(N4JSGrammarAccess.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);
injectorProvider.restoreRegistry();
dummyParser.getRuleName(null);
Map<AbstractElement, String> nameMappings = new ReflectExtensions().get(dummyParser, "nameMappings");
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 });
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations