Is it possible to generate Java code from a resource only loaded in memory? [message #1802418] |
Fri, 08 February 2019 09:40  |
Eclipse User |
|
|
|
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 10:47  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04417 seconds