Code generation technology based on eclipse platform

Source: Internet
Author: User

Introduction: Code generation technology is a common way to reduce workload in project construction, but most developers don't know much about the code generation technology under the Eclipse platform. This article details the techniques for code generation under the Eclipse platform, including the use of Eclipse's own template engine JET, the technology used for Eclipse Project generation, and related assistive technologies for code generation under the Eclipse platform. This article will benefit both the software architect and the Eclipse developer.

Eclipse's Java Emitter templates (JET) is an open source template engine that is capable of generating code in the Eclipse Modeling Framework (EMF). The syntax of JET is similar to JSP syntax, but they are in different areas of application.

JET's template file (template files) suffix is generally (*.jet), but it is recommended that the extension take the form of a makefile type plus a jet suffix, such as ***.javajet, ***.textjet, for the type that distinguishes the generated file.

Org.eclipse.emf.codegen.jet.JETEmitter is the core class of jet, and its generate () method accomplishes two functions, transforming the template file into a template execution class (template implementation Class) and then generates the appropriate code or text from the output of the template execution class.

Figure 1. Text Generation flowchart

View artwork (larger)

JET Application Example

This article comes with three sample source code, the three examples described below correspond to the Demo1, Demo2, and Demo3 in the sample source code, and the specific method in the example is written in the Dofinish method of the example source code Samplenewwizard. After you run the sample project in Eclipse application, select Menu Filenewother on the newly running Eclipse platform, select JET Sample Wizards Demo1 to Demo3 in the new dialog box that pops up The dialog box fills in the appropriate content to display the sample effect.

Figure 2. JET Sample Wizards

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.