Skip to main content



      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 08:17 Go to next message
Eclipse UserFriend
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 03:13 Go to previous messageGo to next message
Eclipse UserFriend
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 03:19 Go to previous messageGo to next message
Eclipse UserFriend
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 10:11 Go to previous messageGo to next message
Eclipse UserFriend
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 10:45 Go to previous messageGo to next message
Eclipse UserFriend
Solution is to use XtextLiveScopeResourceSetProvider
Re: Saving Multiple Xtext Resources with Cyclic Cross References [message #1799065 is a reply to message #1766197] Thu, 29 November 2018 08:36 Go to previous messageGo to next message
Eclipse UserFriend
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 09:07 Go to previous message
Eclipse UserFriend
can you provide a complete minimal example?
Previous Topic:Formatting keywords
Next Topic:annotationRef with String attribute as a static filed
Goto Forum:
  


Current Time: Fri Jun 20 06:57:39 EDT 2025

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

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

Back to the top