Community
Participate
Working Groups
Hi Dave, I paste in a thread from the newsgroup here: Eike Stepper wrote: > I am trying to use the Ecore JET templates for a GenPackage, but without calling generate(...) directly on the GenPackage. > The reason is, that I can't find a way to prevent generate from also iterating over all the contents (GenClassifiers and so on). > I want only the generated for example the XyzPackageImpl.java to be generated. > > After a day of fiddling I manged with 2 dirty hacks: > > GenModel genModel = genBase.getGenModel(); > genModel.setCanGenerate(true); > > Method setter = BeanHelper.findMethod(genModel.getClass(), "setImportManager"); > setter.setAccessible(true); > setter.invoke(genModel, new Object[] {importManager}); > setter.setAccessible(false); > > because the GenModel.setImportManager() method is protected. > Is there anything against making this method public? > > > And I had to modify the GenPackage source code with several: > > if (dependencyHelper == null) > { > dependencyHelper = new DependencyHelper(); > } > > Why is the dependencyHelper not handled like the switchHelper and the validatorHelper? > > Cheers > /Eike > > Ed Merks wrote: Eike, I've been looking too at how to invoke templates without creating a derived GenModel. For example, I added this public method in the GenBaseImpl as kind of a hack: public void gen (Monitor progressMonitor, int style, List pluginVariables, String targetDirectory, String packageName, String className, JETEmitter jetEmitter) { generate(progressMonitor, style, pluginVariables, targetDirectory, packageName, className, jetEmitter, new Object [] { this }); } Maybe instead of making a bunch of these things kinds of things public, there should perhaps be some "convenience" method that does the setup. Please open a feature request with these details and we can work together on the best way to make this easier. Dave will soon be focused on generator extensibility and this falls right in that category...
I believe that both elements of this request have been addressed as part of bug 75925, which has now been committed to CVS. GeneratorAdapter.generate() only generates code for the specified model element, not it's children. And prepareCache() and clearCache() methods have been added to GenPackage to allow its naming caches to be setup and torn down.
Fixed in 2.2.0RC2 (S200605020900)
Move to verified as per bug 206558.