Splitting to multiple resources [message #703057] |
Wed, 27 July 2011 01:39  |
Eclipse User |
|
|
|
Hi,
The model content is created programatically, in the final step I would like to split the content to multiple xtext resources.
The grammar defines Package as top-level element and initally the model consist a single Package with multiple Modules. For each new resource, I create a new Package and put the corresponding Module there.
This does not work, exception is thrown 'java.lang.RuntimeException: No EObjectDescription could be found is Scope ...'.
If I save to a single resource, all works fine. I guess references are broken. Any idea? Thanks!
ResourceSet resourceSet = new ResourceSetImpl();
for (AbstractPackageElement element : package.getElements()) {
if (element instanceof Module) {
Module moduleElement = (Module) element;
Resource resource=resourceSet.createResource(moduleElement.getName() + ".tsx");
Package container = Factory.eINSTANCE.createPackage();
container .getElements().add(moduleElement);
resource.getContents().add(container);
try {
resource.save(null);
} catch (IOException e) {
e.printStackTrace();
}
}
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05040 seconds