Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Serialization requires names to be "more unique" than other parts of the language implemen
Serialization requires names to be "more unique" than other parts of the language implemen [message #1821237] Fri, 07 February 2020 17:40 Go to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
In one of our DSLs, some root object may contain children of different types, and scoping is set up such that cross references to those children are type aware. As a result the following structure is legal (assume that these are keywords: model, elemA, elemB, refA):
model M1 {
    elemA x
    elemB x
}
model M2 {
    refA M1.x
}


We have two distinct EObjects with qualified name M1.x but different types. Resolving M2.refA is not ambiguous because scoping for feature refA only looks for elements of type ElemA, not ElemB. So, resolving of cross references works. Similarly also NamesAreUnique validation is silent, because EClasses ElemA and ElemB belong to different clusters.

As you can see all is fine, until ... until I try to serialize such a model.

I found this to go awry at the first "return false;" inside org.eclipse.xtext.scoping.impl.SimpleScope.getLocalElementsByEObject(...).new Predicate() {...}.canBeFoundByNameAndShadowingKey(IEObjectDescription). This return false causes serialization to fail because the given link target cannot be found in the scope.

I experimentally fixed this for my case by guarding the return with
	if (input.getEClass().equals(other.getEClass()))

This naively mimics the clustering of NamesAreUnique validation, but probably for a real solution we'd need to access the actual clustering used during validation.

I'm I barking up some wrong tree or is this worth an issue in github?

thanks,
Stephan

Re: Serialization requires names to be "more unique" than other parts of the language impl [message #1821238 is a reply to message #1821237] Fri, 07 February 2020 18:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hmm looking at your description and the code its hard to tell.
but what i dont understand: shouldnt the correct object only be in scope and thus no problem at all?
=> maybe you can provide a small example grammar (+scoping + unit test)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Serialization requires names to be "more unique" than other parts of the language impl [message #1821239 is a reply to message #1821238] Fri, 07 February 2020 19:06 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Shoot, you nailed it. Yep, scoping for one particular cross reference was not specific enough. Indeed the scope contained both objects. My bad.

Of course, normal resolving still just picked the first matching object. So at the surface everything *looked* kosher, without being reliable, though.

Nothing to be done in Xtext :)
Previous Topic:Skiping classes when debugging DSL code
Next Topic:Serializing several resources with cross references
Goto Forum:
  


Current Time: Tue Apr 23 09:43:50 GMT 2024

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

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

Back to the top