use of org.eclipse.xtext.xtext.wizard.Ecore2XtextConfiguration in project xtext-core by eclipse.
the class Ecore2XtextGrammarCreator method grammar.
public CharSequence grammar(final WizardConfiguration config) {
CharSequence _xblockexpression = null;
{
final Ecore2XtextConfiguration it = config.getEcore2Xtext();
UniqueNameUtil.clearUniqueNames(it.getDefaultEPackageInfo());
StringConcatenation _builder = new StringConcatenation();
_builder.append("// automatically generated by Xtext");
_builder.newLine();
_builder.append("grammar ");
String _name = config.getLanguage().getName();
_builder.append(_name);
_builder.append(" with org.eclipse.xtext.common.Terminals");
_builder.newLineIfNotEmpty();
_builder.newLine();
{
Collection<EPackage> _allReferencedEPackages = Ecore2XtextExtensions.allReferencedEPackages(it);
for (final EPackage it_1 : _allReferencedEPackages) {
_builder.append("import \"");
String _nsURI = it_1.getNsURI();
_builder.append(_nsURI);
_builder.append("\" ");
{
if (((UniqueNameUtil.uniqueName(it_1) != null) && (!Objects.equal(UniqueNameUtil.uniqueName(it_1), "")))) {
_builder.append("as ");
String _uniqueName = UniqueNameUtil.uniqueName(it_1);
_builder.append(_uniqueName);
}
}
_builder.newLineIfNotEmpty();
}
}
_builder.newLine();
CharSequence _rules = this.rules(it.getRootElementClass());
_builder.append(_rules);
_builder.newLineIfNotEmpty();
{
List<EClass> _but = this.<EClass>but(Ecore2XtextExtensions.allDispatcherRuleClasses(it), it.getRootElementClass());
for (final EClass it_2 : _but) {
_builder.newLine();
CharSequence _subClassDispatcherRule = this.subClassDispatcherRule(it_2);
_builder.append(_subClassDispatcherRule);
_builder.newLineIfNotEmpty();
}
}
{
List<EClassifier> _but_1 = this.<EClassifier>but(Ecore2XtextExtensions.allConcreteRuleClassifiers(it), it.getRootElementClass());
for (final EClassifier it_3 : _but_1) {
_builder.newLine();
CharSequence _rule = this.rule(it_3);
_builder.append(_rule);
_builder.newLineIfNotEmpty();
}
}
_xblockexpression = _builder;
}
return _xblockexpression;
}
Aggregations