Java Code Examples for org.eclipse.emf.codegen.ecore.genmodel.GenModel#getGenPackages()
The following examples show how to use
org.eclipse.emf.codegen.ecore.genmodel.GenModel#getGenPackages() .
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: EcoreGeneratorFragment.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
/** * Use {@link GenModelAccess#getGenPackage(EPackage, ResourceSet)} */ @Deprecated protected List<GenPackage> loadReferencedGenModels(ResourceSet rs) { List<GenPackage> result = Lists.newArrayList(); if (getReferencedGenModels() != null) { for (String uri : getReferencedGenModels().split(",")) { try { Resource resource = rs.getResource(URI.createURI(uri.trim()), true); GenModel genmodel = (GenModel) resource.getContents().get(0); EList<GenPackage> genPackages = genmodel.getGenPackages(); for (GenPackage genPackage : genPackages) { genPackage.getEcorePackage().getEClassifiers(); result.add(genPackage); } } catch (Exception e) { log.error("Couldn't find genmodel for uri '" + uri + "'"); throw new WrappedException(e); } } } return result; }
Example 2
Source File: EMFGeneratorFragment.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
/** * @since 2.0 */ protected List<GenPackage> getGenPackagesForPackages(GenModel existingGenModel, Collection<EPackage> packs) { List<GenPackage> result = Lists.newArrayList(); for (EPackage pkg : packs) { boolean found = false; for (GenPackage gp : existingGenModel.getGenPackages()) if (gp.getEcorePackage() != null && gp.getEcorePackage().getNsURI() != null && gp.getEcorePackage().getNsURI().equals(pkg.getNsURI())) found = true; if (!found) result.add(GenModelAccess.getGenPackage(pkg, existingGenModel.eResource().getResourceSet())); } Collections.sort(result, new Comparator<GenPackage>() { @Override public int compare(GenPackage o1, GenPackage o2) { return EcoreUtil.getURI(o1).toString().compareTo(EcoreUtil.getURI(o2).toString()); } }); return result; }
Example 3
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 4
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; }