use of org.eclipse.emf.mwe.utils.GenModelHelper in project xtext-core by eclipse.
the class EMFGeneratorFragment2 method getSaveAndReconcileGenModel.
protected GenModel getSaveAndReconcileGenModel(final Grammar grammar, final List<EPackage> packs, final ResourceSet rs) {
final GenModel genModel = this.getGenModel(rs, grammar);
genModel.initialize(packs);
EList<GenPackage> _genPackages = genModel.getGenPackages();
for (final GenPackage genPackage : _genPackages) {
{
genPackage.setBasePackage(this.getBasePackage(grammar));
if (this.suppressLoadInitialization) {
genPackage.setLoadInitialization(false);
}
if (((!this.getLanguage().getFileExtensions().isEmpty()) && packs.contains(genPackage.getEcorePackage()))) {
genPackage.setFileExtensions(IterableExtensions.join(this.getLanguage().getFileExtensions(), ","));
}
}
}
final Set<EPackage> referencedEPackages = this.getReferencedEPackages(packs);
final List<GenPackage> usedGenPackages = this.getGenPackagesForPackages(genModel, referencedEPackages);
this.reconcileMissingGenPackagesInUsedModels(usedGenPackages);
genModel.getUsedGenPackages().addAll(usedGenPackages);
this.saveResource(genModel.eResource());
new GenModelHelper().registerGenModel(genModel);
return genModel;
}
use of org.eclipse.emf.mwe.utils.GenModelHelper in project xtext-core by eclipse.
the class EMFGeneratorFragment2 method registerUsedGenModel.
private void registerUsedGenModel(final URIConverter converter, final Grammar grammar) {
final URI genModelUri = this.getGenModelUri(grammar);
boolean _exists = converter.exists(genModelUri, null);
if (_exists) {
try {
GenModelHelper _genModelHelper = new GenModelHelper();
XtextResourceSet _xtextResourceSet = new XtextResourceSet();
_genModelHelper.registerGenModel(_xtextResourceSet, genModelUri);
} catch (final Throwable _t) {
if (_t instanceof Exception) {
final Exception e = (Exception) _t;
EMFGeneratorFragment2.LOG.error("Failed to register GenModel", e);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
}
Aggregations