Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 125469 - CodeGen Reusability
Summary: CodeGen Reusability
Status: VERIFIED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: Tools (show other bugs)
Version: 2.2   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Dave Steinberg CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 75925
Blocks:
  Show dependency tree
 
Reported: 2006-01-27 09:10 EST by Eike Stepper CLA
Modified: 2008-01-28 16:46 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eike Stepper CLA 2006-01-27 09:10:46 EST
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...
Comment 1 Dave Steinberg CLA 2006-05-01 11:20:21 EDT
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.
Comment 2 Nick Boldt CLA 2006-05-02 11:17:47 EDT
Fixed in 2.2.0RC2 (S200605020900)
Comment 3 Nick Boldt CLA 2008-01-28 16:46:14 EST
Move to verified as per bug 206558.