Papyrus has already have code generation support for C++ and Java programming languages. Besides, support for Ada and C programming languages are also on the way. However, it is possible to develop and integrate new code generators for other programming languages to Papyrus. In this article you will find how add a new code generator to Papyrus from scratch.

Preparing the Development Environment (Prerequisites)

This section provides a step-by-step guide to set up your development environment in order to be able to add a new code generator for Papyrus.

Assuming that you have already installed Papyrus, here are the steps you need to follow:

http://download.eclipse.org/modeling/mdt/papyrus/components/designer/

Preparing the Required Projects

To be able to develop a new code generator for a programming language (let's say the X programming language), you need to create three different (but interrelated) projects.

In the sequel, we will use the shorthands oep for org.eclipse.papyrus and oepdl for org.eclipse.papyrus.designer.languages for a better readability. Of course, the full names need to be used in your plugins. Please also note that the screenshots still use a shorter prefix which has been used in a previous version.

Now, let's create and prepare all these projects one by one.

The Main Code Generation Project for the Hypothetical X Programming Language

Here are the steps for creating and setting the oepdl.x.codegen project:

CAVEAT: the following screenshots are not up to date and relate to a previous version in which a single extension (with a different prefix) point is used for code and project creation. It may be useful to look at the C++ and Java code generators available via the Papyrus SW designer git

The User Interface Project

Here are the steps for creating and setting the oepdl.x.codegen.ui project:

If all the steps worked fine, you can go on by creating the test project of your code generator.

The Test Project

Here are the steps for creating and setting the "oepdl.x.codegen.tests" project:

Developing the New Code Generator

To develop a new code generator, you will use the Xtend language. For starting Xtend, see the Xtend introductory video and the Xtend documentation.

Basic Configuration

Here are the basic configuration steps for developing the example code generator:

Advanced Options

Generating the Code in a New Project

Dealing with Errors

Integrating the New Code Generator to Papyrus SW Designer

The ultimate goal of developing a new code generator is to make it available to all users. If you want to integrate your new code generator into Papyrus SW Designer, just contact with us.