Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xtext] Bidirectional properties handled incorrectly?
[Xtext] Bidirectional properties handled incorrectly? [message #61030] Mon, 20 July 2009 10:35 Go to next message
Jos Warmer is currently offline Jos WarmerFriend
Messages: 66
Registered: July 2009
Member
We use an existing ecore metamodel with Xtext. In the metamodel we make
use of bidirectional references. When either doing validation checks using
Checks, or generating using Xpand the opposite side of references remains
null.

Sofar I have two different cases:
1. If an opposite points to its owner, things are ok.
2. If an opposite does not point to its owner, it is never set. Only the
side that is mentioned in the Xtext grammar rule, is set, but the opposite
remains empty.

I have encountered this while migrating Mod4j, and can reproduce this in a
small example. I can send the corresponding files, but don't know how to
add them in this newsgroup.

Is this a known problem that anyone has seen before? I can't find
anything on this newsgroup.

Regards, Jos Warmer
Re: [Xtext] Bidirectional properties handled incorrectly? [message #61106 is a reply to message #61030] Mon, 20 July 2009 11:57 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Jos,

this is a know bug.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=282486

Regards,
Sebastian

--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 20.07.2009 12:35 Uhr, schrieb Jos Warmer:
> We use an existing ecore metamodel with Xtext. In the metamodel we make
> use of bidirectional references. When either doing validation checks
> using Checks, or generating using Xpand the opposite side of references
> remains null.
>
> Sofar I have two different cases:
> 1. If an opposite points to its owner, things are ok.
> 2. If an opposite does not point to its owner, it is never set. Only the
> side that is mentioned in the Xtext grammar rule, is set, but the
> opposite remains empty.
>
> I have encountered this while migrating Mod4j, and can reproduce this in
> a small example. I can send the corresponding files, but don't know how
> to add them in this newsgroup.
>
> Is this a known problem that anyone has seen before? I can't find
> anything on this newsgroup.
>
> Regards, Jos Warmer
>
>
>
Re: [Xtext] Bidirectional properties handled incorrectly? [message #61182 is a reply to message #61106] Mon, 20 July 2009 13:15 Go to previous messageGo to next message
Jos Warmer is currently offline Jos WarmerFriend
Messages: 66
Registered: July 2009
Member
Hi Sebastian,

I checked the newsgroup, but I'll check bugzilla as well next time.
Is this resolved in Xtext 0.7.1 ?, this is really a showstopper for us.

Jos
Re: [Xtext] Bidirectional properties handled incorrectly? [message #61230 is a reply to message #61182] Mon, 20 July 2009 13:31 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Jos,

this issue has not been resolved so far, but I'll double check the
attached patch for SR2. However, I cannot promise that it will make it
into 0.7.2.

Regards,
Sebastian

--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 20.07.2009 15:15 Uhr, schrieb Jos Warmer:
> Hi Sebastian,
>
> I checked the newsgroup, but I'll check bugzilla as well next time.
> Is this resolved in Xtext 0.7.1 ?, this is really a showstopper for us.
>
> Jos
>
Re: [Xtext] Bidirectional properties handled incorrectly? [message #61254 is a reply to message #61182] Mon, 20 July 2009 13:36 Go to previous messageGo to next message
Knut Wannheden is currently offline Knut WannhedenFriend
Messages: 298
Registered: July 2009
Senior Member
Hi Jos,

Also note the documented workarounds: Either set the resolveProxies
property to "false" on the EReferences set by the Xtext parser or
override the LazyLinker implementation for these references as outlined
in the bug description.

Regards,

--knut

Jos Warmer wrote:
> Hi Sebastian,
>
> I checked the newsgroup, but I'll check bugzilla as well next time.
> Is this resolved in Xtext 0.7.1 ?, this is really a showstopper for us.
>
> Jos
>
Re: [Xtext] Bidirectional properties handled incorrectly? [message #61375 is a reply to message #61254] Mon, 20 July 2009 15:07 Go to previous messageGo to next message
Jos Warmer is currently offline Jos WarmerFriend
Messages: 66
Registered: July 2009
Member
Hi Knut,

Thanks for the advice. I see the overriding of the createProxy()
operation, and found the xtext LazyLinking class that I should override.

@Override
protected EObject createProxy(EObject obj, AbstractNode abstractNode,
EReference eRef) {
EReference eOpposite = ((Internal) eRef).getEOpposite();
if (eOpposite != null) {
List<EObject> linkedObjects =
MyLinkingService.INSTANCE
.getLinkedObjects(obj, eRef,
abstractNode);
if (linkedObjects.size() == 1)
return linkedObjects.get(0);
}
return super.createProxy(obj, abstractNode, eRef);
}

What I cannot see is which "MyLinkingService.INSTANCE" the code is
referring to. Should I also change the default XTextLinkingService ?

I think I like the first resolution (set the resolveProxies ...) better,
but I dopn't know where I can get into the Xtext processing to change
these properties. Do you have a pointer for me?

Jos

Knut Wannheden wrote:

> Hi Jos,

> Also note the documented workarounds: Either set the resolveProxies
> property to "false" on the EReferences set by the Xtext parser or
> override the LazyLinker implementation for these references as outlined
> in the bug description.

> Regards,

> --knut

> Jos Warmer wrote:
Re: [Xtext] Bidirectional properties handled incorrectly? [message #61423 is a reply to message #61375] Mon, 20 July 2009 15:24 Go to previous messageGo to next message
Knut Wannheden is currently offline Knut WannhedenFriend
Messages: 298
Registered: July 2009
Senior Member
Hi Jos,

Jos Warmer wrote:
> Hi Knut,
>
> Thanks for the advice. I see the overriding of the createProxy()
> operation, and found the xtext LazyLinking class that I should override.
>
> @Override
> protected EObject createProxy(EObject obj, AbstractNode abstractNode,
> EReference eRef) {
> EReference eOpposite = ((Internal) eRef).getEOpposite();
> if (eOpposite != null) {
> List<EObject> linkedObjects =
> MyLinkingService.INSTANCE
> .getLinkedObjects(obj, eRef,
> abstractNode);
> if (linkedObjects.size() == 1)
> return linkedObjects.get(0);
> }
> return super.createProxy(obj, abstractNode, eRef);
> }
>
> What I cannot see is which "MyLinkingService.INSTANCE" the code is
> referring to. Should I also change the default XTextLinkingService ?
>

The method createProxy can actually be overridden in a simpler way. I
think this should work (not tested):

@Override
protected EObject createProxy(EObject obj, AbstractNode
abstractNode, EReference eRef) {
final EObject proxy = super.createProxy(obj, abstractNode, eRef);
if (eRef.getEOpposite() != null) {
return EcoreUtil.resolve(proxy, obj);
}
return proxy;
}


> I think I like the first resolution (set the resolveProxies ...) better,
> but I dopn't know where I can get into the Xtext processing to change
> these properties. Do you have a pointer for me?
>

As you have references with opposites I assumed your Ecore model already
existed and wasn't inferred by Xtext. If that's the case you can set the
resolveProxies attribute in the Ecore file.

Keep in mind that both these approaches are workarounds only.

--knut
Re: [Xtext] Bidirectional properties handled incorrectly? [message #61553 is a reply to message #61423] Mon, 20 July 2009 16:34 Go to previous messageGo to next message
Jos Warmer is currently offline Jos WarmerFriend
Messages: 66
Registered: July 2009
Member
Knut,

Your new createProxy() method works fine for both the example and for the
larger languages.

The resolve proxies in the ecore file are all "true" already. It seems
that this does not solve the problem.

I know this is a workaround, but this issue is a blocking one for me. So
thanks for helping me out.

Jos
Re: [Xtext] Bidirectional properties handled incorrectly? [message #61602 is a reply to message #61553] Mon, 20 July 2009 18:57 Go to previous message
Knut Wannheden is currently offline Knut WannhedenFriend
Messages: 298
Registered: July 2009
Senior Member
Hi Jos,

Jos Warmer wrote:
> Your new createProxy() method works fine for both the example and for the
> larger languages.
>
> The resolve proxies in the ecore file are all "true" already. It seems
> that this does not solve the problem.
>

You actually would have to set it to "false" for those references. Of
course you would have to check that doesn't cause problems for other
usages and consumers of the meta model. But it probably wouldn't.

Cheers,

--knut
Previous Topic:Importing XML schema as metamodel?
Next Topic:Merging model files before running XPand
Goto Forum:
  


Current Time: Mon Jul 22 07:31:24 GMT 2024

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

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

Back to the top