Difference between revisions of "EMF/ExtendingCodeGeneration"

From Eclipsepedia

< EMF
Jump to: navigation, search
(GeneratorAdapter Class)
(Links)
Line 44: Line 44:
 
* http://www.eclipse.org/forums/index.php?t=msg&S=26948a7500a8f8b49cfde1a577ad810c&th=155261&goto=48916
 
* http://www.eclipse.org/forums/index.php?t=msg&S=26948a7500a8f8b49cfde1a577ad810c&th=155261&goto=48916
 
* http://www.eclipse.org/forums/index.php?t=msg&goto=647243&S=26948a7500a8f8b49cfde1a577ad810c#msg_647243
 
* http://www.eclipse.org/forums/index.php?t=msg&goto=647243&S=26948a7500a8f8b49cfde1a577ad810c#msg_647243
 +
 +
Here another example:
 +
http://code.google.com/a/eclipselabs.org/p/emf/source/browse/#hg%2Forg.eclipselabs.emf.codegen.addon

Revision as of 12:06, 8 January 2011

Summary

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

The a reference 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)

Links

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