Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Saving Multiple Xtext Resources with Cyclic Cross References
Saving Multiple Xtext Resources with Cyclic Cross References [message #1719119] Tue, 05 January 2016 13:17 Go to next message
Stephan Hildebrandt is currently offline Stephan HildebrandtFriend
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
Re: Saving Multiple Xtext Resources with Cyclic Cross References [message #1719201 is a reply to message #1719119] Wed, 06 January 2016 08:13 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
Hi Stephan,

in validatin, you can set @check to EXPENSIVE so that it is ONLY executed when you start Validation from the popup-menu.
This may solve the situation you described when two DSLs are changed simultaniously.

public enum CheckType {
FAST,
NORMAL,
EXPENSIVE;
}

during editing with a delay of 500ms, only FAST is passed
on save NORMAL is passed
an action, which can be optionally generated for you DSL, explicitly evaluates EXPENSIVE constraints
Re: Saving Multiple Xtext Resources with Cyclic Cross References [message #1719205 is a reply to message #1719201] Wed, 06 January 2016 08:19 Go to previous messageGo to next message
Stephan Hildebrandt is currently offline Stephan HildebrandtFriend
Messages: 25
Registered: July 2015
Junior Member
Hi Uli,

the problem has nothing to do with validation. It already occurrs before any validation takes place. I programmatically build the models and the exception occurrs when I try to save them.


Best regards,

Stephan
Re: Saving Multiple Xtext Resources with Cyclic Cross References [message #1766195 is a reply to message #1719205] Sat, 17 June 2017 14:11 Go to previous messageGo to next message
Puneet Patwari is currently offline Puneet PatwariFriend
Messages: 64
Registered: November 2014
Member
Hi All

I have the same problem as described by Stephen. I am programmatically creating multiple xtext files referencing each other. When I try to save them using resource.save(null) I get an error No EObjectDescription Found in scope.. The problem gets resolved if I add a Thread.sleep(5000) but this is not the right solution. Can anyone please help?

NOTE: I am using a context menu to call the generatot created separately by me as described by Stephen in first message.

Thanks in Advance.
Puneet
Re: Saving Multiple Xtext Resources with Cyclic Cross References [message #1766197 is a reply to message #1766195] Sat, 17 June 2017 14:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14667
Registered: July 2009
Senior Member
Solution is to use XtextLiveScopeResourceSetProvider

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Saving Multiple Xtext Resources with Cyclic Cross References [message #1799065 is a reply to message #1766197] Thu, 29 November 2018 13:36 Go to previous messageGo to next message
Amar Banerjee is currently offline Amar BanerjeeFriend
Messages: 14
Registered: November 2018
Junior Member
Hi everyone,
I have been using XtextLiveResourceSetProvider to create a fresh resourceSet so as to generate multiple dsl files with corss references. It still does not work and I keep getting the same old error...

No EObjectDescription could be found in Scope...

Any idea about why the models are not able to serialize ??

Thanks in advance Xtexters !!
Re: Saving Multiple Xtext Resources with Cyclic Cross References [message #1799073 is a reply to message #1799065] Thu, 29 November 2018 14:07 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14667
Registered: July 2009
Senior Member
can you provide a complete minimal example?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Formatting keywords
Next Topic:annotationRef with String attribute as a static filed
Goto Forum:
  


Current Time: Fri Apr 26 17:43:19 GMT 2024

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

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

Back to the top