Java Code Examples for org.eclipse.emf.codegen.ecore.genmodel.GenModel#initialize()
The following examples show how to use
org.eclipse.emf.codegen.ecore.genmodel.GenModel#initialize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EMFGeneratorFragment.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
/** * @since 2.0 */ protected GenModel getSaveAndReconcileGenModel(ResourceSet rs, Grammar grammar, XpandExecutionContext ctx, List<EPackage> packs) throws ConfigurationException { GenModel genModel = getGenModel(rs, grammar, ctx, packs); genModel.initialize(packs); for (GenPackage genPackage : genModel.getGenPackages()) { genPackage.setBasePackage(getBasePackage(grammar)); if (isSuppressLoadInitialization()) { genPackage.setLoadInitialization(false); } if (getFileExtensions() != null && packs.contains(genPackage.getEcorePackage())) { genPackage.setFileExtensions(getFileExtensions()); } } Set<EPackage> referencedEPackages = getReferencedEPackages(packs); List<GenPackage> usedGenPackages = getGenPackagesForPackages(genModel, referencedEPackages); reconcileMissingGenPackagesInUsedModels(usedGenPackages); genModel.getUsedGenPackages().addAll(usedGenPackages); try { saveResource(genModel.eResource()); } catch (IOException e) { throw new WrappedException(e); } new GenModelHelper().registerGenModel(genModel); return genModel; }
Example 2
Source File: EMFGeneratorFragment2.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
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; }
Example 3
Source File: DataObjectGenerator.java From BIMserver with GNU Affero General Public License v3.0 | 5 votes |
public VirtualFile generate(VirtualFile basedir) throws DatabaseException { GenModel genModel = GenModelFactory.eINSTANCE.createGenModel(); genModel.setRuntimeVersion(GenRuntimeVersion.EMF25); genModel.setComplianceLevel(GenJDKLevel.JDK60_LITERAL); genModel.setFeatureDelegation(GenDelegationKind.REFLECTIVE_LITERAL); genModel.setRootExtendsClass("org.bimserver.emf.IdEObjectImpl"); genModel.setRootExtendsInterface("org.bimserver.emf.IdEObject"); genModel.setSuppressContainment(true); genModel.setCodeFormatting(true); genModel.setCopyrightText(StringUtils.readFromFile(new File("copyright.txt"))); genModel.setCanGenerate(true); genModel.setModelDirectory("test"); genModel.setModelName("model name"); genModel.setForceOverwrite(true); genModel.setSuppressNotification(false); genModel.setContainmentProxies(false); genModel.setBinaryCompatibleReflectiveMethods(false); genModel.setPublicConstructors(false); genModel.setMinimalReflectiveMethods(true); // More code, but faster genModel.setUpdateClasspath(false); genModel.initialize(schema.getEPackages()); GeneratorAdapterFactory.Descriptor.Registry.INSTANCE.addDescriptor(GenModelPackage.eNS_URI, GenModelGeneratorAdapterFactory.DESCRIPTOR); Generator generator = new Generator(); generator.setInput(genModel); generator.generate(genModel, GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE, new BasicMonitor.Printing(System.out)); // List<GenPackage> genPackages = createGenPackages(genModel, basedir); // generatePackages(genModel, genPackages, basedir); return basedir; }