Search in sources :

Example 1 with GenModelImpl

use of org.eclipse.emf.codegen.ecore.genmodel.impl.GenModelImpl in project xtext-core by eclipse.

the class EMFGeneratorFragment2 method getGenModel.

protected GenModel getGenModel(final ResourceSet rs, final Grammar grammar) {
    try {
        final URI genModelUri = this.getGenModelUri(grammar);
        final Resource resource = rs.getResource(genModelUri, false);
        if ((resource != null)) {
            resource.unload();
            rs.getResources().remove(resource);
        }
        final Resource genModelFile = rs.createResource(genModelUri, ContentHandler.UNSPECIFIED_CONTENT_TYPE);
        GenModel genModel = null;
        boolean _exists = rs.getURIConverter().exists(genModelUri, null);
        if (_exists) {
            genModelFile.load(null);
            boolean _hasFragment = genModelUri.hasFragment();
            if (_hasFragment) {
                EObject _eObject = genModelFile.getEObject(genModelUri.fragment());
                genModel = ((GenModel) _eObject);
            } else {
                EObject _head = IterableExtensions.<EObject>head(genModelFile.getContents());
                genModel = ((GenModel) _head);
            }
        } else {
            genModel = new GenModelImpl() {

                @Override
                public GenPackage createGenPackage() {
                    return new GenPackageImpl() {

                        @Override
                        public String getSerializedPackageFilename() {
                            String _name = this.getName();
                            return (_name + ".loadinitialization_ecore");
                        }
                    };
                }
            };
            genModel.setModelName(this.getModelName(grammar));
            genModel.setModelPluginID(this.getModelPluginID());
            genModel.setModelDirectory(this.getJavaModelDirectory());
            if (this.generateEdit) {
                genModel.setEditPluginID(this.getEditPluginID());
                genModel.setEditDirectory(this.getEditDirectory());
            }
            if (this.generateEditor) {
                genModel.setEditorPluginID(this.getEditorPluginID());
                genModel.setEditorDirectory(this.getEditorDirectory());
            }
            genModel.setValidateModel(false);
            genModel.setForceOverwrite(true);
            genModel.setFacadeHelperClass(null);
            genModel.setBundleManifest(true);
            genModel.setUpdateClasspath(false);
            genModel.setComplianceLevel(this.jdkLevel);
            genModel.setRuntimeVersion(this.emfRuntimeVersion);
            genModel.setRootExtendsClass("org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container");
            genModel.setLineDelimiter(this.codeConfig.getLineDelimiter());
            String _fileHeader = this.codeConfig.getFileHeader();
            boolean _tripleNotEquals = (_fileHeader != null);
            if (_tripleNotEquals) {
                genModel.setCopyrightText(EMFGeneratorFragment2.trimMultiLineComment(this.codeConfig.getFileHeader()));
            }
        }
        genModelFile.getContents().add(genModel);
        return genModel;
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : GenModel(org.eclipse.emf.codegen.ecore.genmodel.GenModel) EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) Resource(org.eclipse.emf.ecore.resource.Resource) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource) GenModelImpl(org.eclipse.emf.codegen.ecore.genmodel.impl.GenModelImpl) GenPackage(org.eclipse.emf.codegen.ecore.genmodel.GenPackage) URI(org.eclipse.emf.common.util.URI) GenPackageImpl(org.eclipse.emf.codegen.ecore.genmodel.impl.GenPackageImpl)

Aggregations

GenModel (org.eclipse.emf.codegen.ecore.genmodel.GenModel)1 GenPackage (org.eclipse.emf.codegen.ecore.genmodel.GenPackage)1 GenModelImpl (org.eclipse.emf.codegen.ecore.genmodel.impl.GenModelImpl)1 GenPackageImpl (org.eclipse.emf.codegen.ecore.genmodel.impl.GenPackageImpl)1 URI (org.eclipse.emf.common.util.URI)1 EObject (org.eclipse.emf.ecore.EObject)1 InternalEObject (org.eclipse.emf.ecore.InternalEObject)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 XMLResource (org.eclipse.emf.ecore.xmi.XMLResource)1