use of org.eclipse.emf.codegen.ecore.genmodel.impl.GenPackageImpl 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);
}
}
Aggregations