Saving Multiple Xtext Resources with Cyclic Cross References [message #1719119] |
Tue, 05 January 2016 13:17 |
Stephan Hildebrandt Messages: 25 Registered: July 2015 |
Junior Member |
|
|
Hi,
I have multiple models with arbitrary cross references between each other, in particular, between two models A and B, there can be references from A to B and vice versa. Each model is stored in its own Xtext resource. When I save the resources, an exception is thrown because no EObjectDescription can be found in the scope for a cross reference to an element in another resource that has not been saved already. My code looks like this:
val IProject project = //get the project from somewhere
val resourceSetProvider = Activator.^default.injector.getInstance(XtextLiveScopeResourceSetProvider)
val resourceSet = resourceSetProvider.get(project)
// Create the models and a resource in the resource set for each model
resourceSet.resources.forEach [ resource |
resource.save(null)
]
The scope provider looks like this:
@Inject
private StandardLibrary standardLibrary
@Inject
private IQualifiedNameProvider qualifiedNameProvider
def IScope scope_TypedElement_type(TypedElement typedElement, EReference ref) {
val delegateScope = delegateGetScope(typedElement, ref)
return SelectableBasedScope.createScope(delegateScope,
new MultimapBasedSelectable(Scopes.scopedElementsFor(standardLibrary.allElements, qualifiedNameProvider)),
TypesPackage.Literals.TYPE, false);
}
Essentially, it creates a new scope, which contains the types of my standard library and delegates to the default scoping behavior in all other cases.
I suspect the root cause of the problem lies somewhere in the scope provider's default behavior because the scope it returns does not seem to contain all elements in the resource set but only those in the same resource like the typedElement, as well as resources that have been saved already. What do I have to do to properly save the resources?
Thanks in advance
Stephan
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03836 seconds