use of org.eclipse.xtext.xtext.generator.XtextGeneratorLanguage in project xtext-core by eclipse.
the class XtextGenerator method initialize.
public void initialize() {
if ((this.injector == null)) {
XtextGenerator.LOG.info("Initializing Xtext generator");
new StandaloneSetup().addRegisterGeneratedEPackage("org.eclipse.xtext.common.types.TypesPackage");
this.initializeEncoding();
this.injector = this.createInjector();
this.injector.injectMembers(this);
CodeConfig _instance = this.injector.<CodeConfig>getInstance(CodeConfig.class);
final Procedure1<CodeConfig> _function = (CodeConfig it) -> {
it.initialize(this.injector);
};
ObjectExtensions.<CodeConfig>operator_doubleArrow(_instance, _function);
this.projectConfig.initialize(this.injector);
this.cleaner.initialize(this.injector);
this.standaloneSetup.initialize(this.injector);
for (final XtextGeneratorLanguage language : this.languageConfigs) {
{
final Injector languageInjector = this.createLanguageInjector(this.injector, language);
language.initialize(languageInjector);
}
}
}
}
use of org.eclipse.xtext.xtext.generator.XtextGeneratorLanguage in project xtext-core by eclipse.
the class XtextGenerator method generateExecutableExtensionFactory.
protected void generateExecutableExtensionFactory(final IXtextGeneratorLanguage language) {
IXtextGeneratorFileSystemAccess _srcGen = this.projectConfig.getEclipsePlugin().getSrcGen();
boolean _tripleNotEquals = (_srcGen != null);
if (_tripleNotEquals) {
this.templates.createEclipsePluginExecutableExtensionFactory(language, IterableExtensions.<XtextGeneratorLanguage>head(this.languageConfigs)).writeTo(this.projectConfig.getEclipsePlugin().getSrcGen());
}
}
use of org.eclipse.xtext.xtext.generator.XtextGeneratorLanguage in project xtext-core by eclipse.
the class XtextGenerator method generateServices.
protected void generateServices() {
if (((this.projectConfig.getGenericIde().getSrcGen() == null) || this.languageConfigs.isEmpty())) {
return;
}
final TextFileAccess file = new TextFileAccess();
file.setPath("META-INF/services/org.eclipse.xtext.ISetup");
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
{
for (final XtextGeneratorLanguage lang : XtextGenerator.this.languageConfigs) {
TypeReference _genericIdeSetup = XtextGenerator.this.naming.getGenericIdeSetup(lang.getGrammar());
_builder.append(_genericIdeSetup);
_builder.newLineIfNotEmpty();
}
}
}
};
file.setContent(_client);
file.writeTo(this.projectConfig.getGenericIde().getSrcGen());
}
use of org.eclipse.xtext.xtext.generator.XtextGeneratorLanguage in project xtext-core by eclipse.
the class XtextGenerator method checkConfigurationInternal.
@Override
protected void checkConfigurationInternal(final Issues issues) {
this.initialize();
final MweIssues generatorIssues = new MweIssues(this, issues);
this.configuration.checkConfiguration(generatorIssues);
final HashMap<String, Grammar> uris = new HashMap<String, Grammar>();
for (final XtextGeneratorLanguage language : this.languageConfigs) {
{
language.checkConfiguration(generatorIssues);
Iterable<GeneratedMetamodel> _filter = Iterables.<GeneratedMetamodel>filter(language.getGrammar().getMetamodelDeclarations(), GeneratedMetamodel.class);
for (final GeneratedMetamodel generatedMetamodel : _filter) {
{
final String nsURI = generatedMetamodel.getEPackage().getNsURI();
boolean _containsKey = uris.containsKey(nsURI);
if (_containsKey) {
String _name = uris.get(nsURI).getName();
String _plus = ((("Duplicate generated grammar with nsURI \'" + nsURI) + "\' in ") + _name);
String _plus_1 = (_plus + " and ");
String _name_1 = language.getGrammar().getName();
String _plus_2 = (_plus_1 + _name_1);
generatorIssues.addError(_plus_2);
} else {
uris.put(nsURI, language.getGrammar());
}
}
}
}
}
}
use of org.eclipse.xtext.xtext.generator.XtextGeneratorLanguage in project xtext-core by eclipse.
the class XtextGenerator method invokeInternal.
@Override
protected void invokeInternal(final WorkflowContext ctx, final ProgressMonitor monitor, final Issues issues) {
this.initialize();
try {
this.cleaner.clean();
for (final XtextGeneratorLanguage language : this.languageConfigs) {
try {
String _name = language.getGrammar().getName();
String _plus = ("Generating " + _name);
XtextGenerator.LOG.info(_plus);
language.generate();
this.generateSetups(language);
this.generateModules(language);
this.generateExecutableExtensionFactory(language);
} catch (final Throwable _t) {
if (_t instanceof Exception) {
final Exception e = (Exception) _t;
this.handleException(e, issues);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
XtextGenerator.LOG.info("Generating common infrastructure");
this.generatePluginXmls();
this.generateManifests();
this.generateActivator();
this.generateServices();
} catch (final Throwable _t_1) {
if (_t_1 instanceof Exception) {
final Exception e_1 = (Exception) _t_1;
this.handleException(e_1, issues);
} else {
throw Exceptions.sneakyThrow(_t_1);
}
}
}
Aggregations