Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xtend2] Builder Pattern: Cross References
[Xtend2] Builder Pattern: Cross References [message #757885] Fri, 18 November 2011 12:26 Go to next message
Hauke Fuhrmann is currently offline Hauke FuhrmannFriend
Messages: 333
Registered: July 2009
Senior Member
Hi there,

I love the new Xtend2 Builder Pattern that you can use since the new
Closure syntax in Xtend as presented by Sven

http://blog.efftinge.de/2011/10/xtend-21-type-safe-groovy-style-builder.html

This allows to create containment trees of elements very elegantly like
Sven shows in the HTML example.

Is there a good solution how to integrate cross references between the
elements also beautifully? I only came up with something like this:

graph[
node[name="a"]
node[name="b"]
node[name="c"]
edge[connect("a","b")]
edge[connect("b","c")]
]

where the connect function uses eContainer to search the containment
hierarchy for nodes with the corresponding names. This seems to be
rather brittle as it will notice only at runtime that a corresponding
element is not there.

As crossreferences may be a very common case, maybe there is a generic
solution to that? Maybe like giving results of the closures a name or
something such that you can address closure elements from other
elements? Hmm... dunno, seems to not match the idea of a closure. Any ideas?

Cheers,
Hauke
Re: [Xtend2] Builder Pattern: Cross References [message #758068 is a reply to message #757885] Mon, 21 November 2011 20:32 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6534
Registered: July 2009
Senior Member
hi,

what about using create extensions? you call them n times with the same parameter and will always get the same instance

~Christian
Previous Topic:How i load resources dynamically
Next Topic:getting rid of warning "Disabling JDT..."?
Goto Forum:
  


Current Time: Wed Dec 17 21:41:38 GMT 2014

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

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