Skip to content
Rubén Díaz edited this page Jul 4, 2017 · 21 revisions

CobiGen TypeScript Plug-in

The TypeScript Plug-in enables merging result TS files to existing ones. This plug-in is used at the moment for generate an Angular2 client with all CRUD functionalities enabled. The plug-in also generates de i18n functionality just appending at the end of the word the ES or EN suffixes, to put into the developer knowledge that this words must been translated to the correspondent language. Currently, the generation of Angular2 client requires an ETO java object as input so, there is no need to implement an input reader for ts artifacts for the moment.

Trigger Extensions

As for the Angular2 generation the input is a java object, the trigger expressions (including matchers and variable assignments) are implemented as Java.

Merger extensions

This plugin uses the OASP TypeScript Merger to merge files.

There are currently two merge strategies:

  • merge strategy tsmerge (add the new code respecting the existing is case of conflict)

  • merge strategy tsmerge_override (add the new code overwriting the existent in case of conflict)

The merging of two Angular2 files will be processed as follows:

Mainly, the merge handles the following nodes types:

  1. ImportDeclaration

  2. ClassDeclaration

  3. PropertyDeclaration

  4. MethodDeclaration

ImportDeclaration

  1. Will add non existent imports whatever the merge strategy is.

  2. For different imports from same module, the import clauses will be merged.

import { a } from 'b';
import { c } from 'b';
//Result
import { a, c } from 'b';

ClassDeclaration

  • Adds non existent base properties from patch based on the name property.

  • Adds non existent base methods from patch based on the name signature.

  • Adds non existent annotations to class, properties and methods.

PropertyDeclaration

  • Adds non existent decorators.

  • Merge existent decorators.

  • With override startegy, the value of the property will be replaced by the patch value.

Method

  • With override startegy, the body will be replaced.

  • The parameters will be merged.

Parameter

  • Replace type and modifiers with override merge strategy, adding non existent from patch into base.

Constructor

  • Merged in the same way as Method is.

FunctionDeclaration

  • Merged in the same way as Method is.

Clone this wiki locally