Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Is it possible to generate Java code from a resource only loaded in memory?(MoDisco - Acceleo)
Is it possible to generate Java code from a resource only loaded in memory? [message #1802418] Fri, 08 February 2019 14:40 Go to next message
Pablo Gomez Abajo is currently offline Pablo Gomez AbajoFriend
Messages: 8
Registered: February 2019
Junior Member
Hi,

I would like to know if it is possible to generate Java code form a resource loaded in memory and not stored in the disk with MoDisco.

I would like to do something like this:

JavaPackage.eINSTANCE.eClass();
GenerateJavaExtended javaGenerator = new GenerateJavaExtended(model, new File(folder), new ArrayList<Object>());
javaGenerator.doGenerate(null);


where the model variable is the resource obtained after applying the MoDisco discoverer to a Java project, which is loaded in memory and modified, and not stored in the disk after these modifications (The expected behavior is that these modifications will be reflected in the generated Java code).

I know there is a version of this GenerateJavaExtended method which accepts an EObject as the first parameter, and I tried to pass the root object of the Java project model as this first argument but didn't manage to make it work.

I manage to make this work but when I serialize the model onto the disk after applying the modifications, and passing the resource's URI as the first argument:

GenerateJavaExtended javaGenerator = new GenerateJavaExtended(model.getURI(), new File(folder), new ArrayList<Object>());


I would appreciate any help. Many thanks in advance,

Pablo


Re: Is it possible to generate Java code from a resource only loaded in memory? [message #1802424 is a reply to message #1802418] Fri, 08 February 2019 15:47 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Sorry, I am not familiar with Modosco, but...

With EMF, everything happens with ResourceImpl's in memory, so the opposite might be a more appropriate question, can Modisco generate from files rather than from memory.

More practically, you need to dig below the API that you reference to find the underlying routines that work with Resources. Single stepping with the debugger is often the easiest way to study the call tree.

Regards

Ed Willink
Previous Topic:Error UML to Java Example
Next Topic:[Acceleo 3.7.7] How to
Goto Forum:
  


Current Time: Fri Apr 19 20:10:35 GMT 2024

Powered by FUDForum. Page generated in 0.02906 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top