Difference between revisions of "EMF/ExtendingCodeGeneration"

From Eclipsepedia

< EMF
Jump to: navigation, search
(Links)
(Links)
Line 57: Line 57:
 
* http://www.eclipse.org/forums/index.php?t=rview&goto=480066&th=152145
 
* http://www.eclipse.org/forums/index.php?t=rview&goto=480066&th=152145
 
* http://www.eclipse.org/forums/index.php?t=msg&goto=415810&S=6b757ff8567e4b1a93cbdc4439a9d208
 
* http://www.eclipse.org/forums/index.php?t=msg&goto=415810&S=6b757ff8567e4b1a93cbdc4439a9d208
 +
* http://www.eclipse.org/forums/index.php?t=msg&th=67851&S=96dfb11d438f65d6a9bce0144b99644e#msg_212916
  
 
One comment here:  
 
One comment here:  

Revision as of 14:11, 9 January 2011

Contents

Summary

The intension of this page to collect experiences of implementing a Generation Adapter.

A sample implementation is the project org.eclipse.emf.examples.generator.validator

(see :pserver:anonymous@dev.eclipse.org:/cvsroot/modeling under org.eclipse.emf/org.eclipse.emf/examples)


GeneratorAdapter Class

The definition links like this

public class GenClassValidatorGeneratorAdapter extends GenBaseGeneratorAdapter
{

The GenBaseGeneratorAdapter base class provide you the basic implementation you have to override:

  • canGenerate
  • generateXXXX

It's depend of the project type what generate method's you override. The following types you know from the menu in the Gen Model.

  • MODEL_PROJECT_TYPE
  • EDIT_PROJECT_TYPE
  • EDITOR_PROJECT_TYPE
  • TESTS_PROJECT_TYPE

In the method canGenerated you have to return true for your project types.

The prefix "GenClass" says this adapter works with the GenClass class of the genmodel.

In accordance to this you have to configure the extension point or you write a GeneratorAdapterFactory. All adapters types are:

  • GenPackage Adapter
  • GenEnum Adapter
  • GenModel Adapter
  • GenClass Adapter

Take care not all combinations and of project type and adapter type produce output. (e.g. I had no luck in the combination GenClass and EDITOR project)

JET Templates

The included JET Templates or better the static JET template classes have to be generated with the "old/basic" JET implementation. (choose "Convert Project to JET Project" in new wizard and do not create a "JET Transformation Project")

The M2T JET project even in JET 1 mode produces a not compatible code: see BUG 333811

Links

Forum entries related to how to compine a generator and dynamic templates

One comment here: The method to add platform:/plugin/<plugin>/templates seems not to work :(

Here another example: http://code.google.com/a/eclipselabs.org/p/emf/source/browse/#hg%2Forg.eclipselabs.emf.codegen.addon