Search in sources :

Example 1 with GenModelHelper

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;
}
Also used : GenModel(org.eclipse.emf.codegen.ecore.genmodel.GenModel) GenModelHelper(org.eclipse.emf.mwe.utils.GenModelHelper) GenPackage(org.eclipse.emf.codegen.ecore.genmodel.GenPackage) EPackage(org.eclipse.emf.ecore.EPackage)

Example 2 with GenModelHelper

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);
            }
        }
    }
}
Also used : XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) GenModelHelper(org.eclipse.emf.mwe.utils.GenModelHelper) URI(org.eclipse.emf.common.util.URI)

Aggregations

GenModelHelper (org.eclipse.emf.mwe.utils.GenModelHelper)2 GenModel (org.eclipse.emf.codegen.ecore.genmodel.GenModel)1 GenPackage (org.eclipse.emf.codegen.ecore.genmodel.GenPackage)1 URI (org.eclipse.emf.common.util.URI)1 EPackage (org.eclipse.emf.ecore.EPackage)1 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)1