vendredi 16 décembre 2016

ECore reflection and cross references

To have a context, I am currently working on an ecore to java model transformation. Practically, I am reading some ecore file and generate a string which happens to be a valid java interface source code.

As a example, here is my code generation workflow.

projectA.ecore:

Defines an EClass 'A'

package projectA : projectA = 'http://ift.tt/2gRNCDF'
{
    class A;
}

projectB.ecore:

Defines an EClass 'B' which inherit from 'A' using cross-reference to a.ecore to get access to it.

import projectA : '../../projectA/model/projectA.ecore#/';

package projectB : projectB = 'http://ift.tt/2h8cljb'
{
    class B extends projectA::A;
}

From those ecore I first generate an interface for projectA.ecore:

package projecta;

interface ProjectA<A> {
  // ...
}

And now I have want to do the same thing for projectB.ecore and obtains the following interface:

package projectb;

import projecta.ProjectA;

interface ProjectB<A,B> extends ProjectA<A> {
  // ...
}

To do so I need to detect that A is and EClass accessed using cross reference and do some analysis in projectA.ecore in order to generate a valid interface extension, packages imports...

I looked around in the ecore reflection API without finding a clean and obvious way to do so. Is this possible? It yes, how?





Aucun commentaire:

Enregistrer un commentaire