use of org.eclipse.xtext.xtext.RuleNames in project xtext-core by eclipse.
the class GrammarAccessExtensions method ruleName.
public String ruleName(final AbstractRule rule) {
final RuleNames ruleNames = RuleNames.tryGetRuleNames(rule);
String _elvis = null;
String _antlrRuleName = null;
if (ruleNames != null) {
_antlrRuleName = ruleNames.getAntlrRuleName(rule);
}
if (_antlrRuleName != null) {
_elvis = _antlrRuleName;
} else {
String _ruleName = AntlrGrammarGenUtil.getRuleName(rule);
_elvis = _ruleName;
}
return _elvis;
}
use of org.eclipse.xtext.xtext.RuleNames in project xtext-core by eclipse.
the class GrammarFlatteningTest method getModel.
public Grammar getModel(final String model, final boolean dropUnreachable) throws Exception {
EObject _model = super.getModel(model);
Grammar grammar = ((Grammar) _model);
RuleNames ruleNames = RuleNames.getRuleNames(grammar, false);
RuleFilter filter = new RuleFilter();
filter.setDiscardUnreachableRules(dropUnreachable);
Grammar result = new FlattenedGrammarAccess(ruleNames, filter).getFlattenedGrammar();
XtextResource resource = this.<XtextResource>get(XtextResource.class);
resource.getContents().add(result);
resource.setURI(URI.createURI("synthetic://flattened.xtext"));
return result;
}
Aggregations