Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » XText complex references - how to ...?
XText complex references - how to ...? [message #468378] Wed, 05 August 2009 10:22 Go to next message
Martin Kuhn is currently offline Martin KuhnFriend
Messages: 49
Registered: July 2009
Member
Hi,

I try to provide nice referencing e.g. like this (with context sensitive
help and so on..)

entity Customer {
attr name: string
}

entity User {
attr name: string
}

dto CustomerDto {
// Reference to entity Customer and attribute name
attrref custName: Customer.name
}


This means that I want to reference an specific attribute of an specific
other entity (here the name attribute of the Customer Entity).

I played around with linking and scoping and so on but I'm not sure what
the right approach is?

1) Grammar definition: I tried it with this approach

EntityAttributeReference:
'attrref' name=ID ':' entity=[Entity] '.' type=[EntityAttribute]
;

2) What are the right locations to provide such functionality


Couldy anybody give me a hint?

TIA

Martin
Re: XText complex references - how to ...? [message #468498 is a reply to message #468378] Wed, 05 August 2009 17:04 Go to previous messageGo to next message
Helko Glathe is currently offline Helko GlatheFriend
Messages: 55
Registered: July 2009
Member
Hi Martin

Perhaps:
Write your own ScopeProvider with a methode like:

IScope scope_EntityAttributeReference_type(EntityAttributeReference ctx,
EReference ref){

Entity e = ctx.getEntity();
if(e != null){
//List with e.getEntityAttributes
//Iterate through all entity attributes
//if an attribute has the name "name"
//I call it <AttributeWithNameName>
List<IScopedElement> result = new
ArrayList<IScopedElement>();

result.add(ScopedElement.create(NameOf<AttributeWithNameName >,
<AttributeWithNameName>));

return new SimpleScope(IScope.NULLSCOPE,result);
}
return IScope.NULLSCOPE;
}

Instead of using "name" you should better use the ref parameter to make it
more general.

Hope thats right ;-)

Helko

Martin Kuhn wrote:

> Hi,

> I try to provide nice referencing e.g. like this (with context sensitive
> help and so on..)

> entity Customer {
> attr name: string
> }

> entity User {
> attr name: string
> }

> dto CustomerDto {
> // Reference to entity Customer and attribute name
> attrref custName: Customer.name
> }


> This means that I want to reference an specific attribute of an specific
> other entity (here the name attribute of the Customer Entity).

> I played around with linking and scoping and so on but I'm not sure what
> the right approach is?

> 1) Grammar definition: I tried it with this approach

> EntityAttributeReference:
> 'attrref' name=ID ':' entity=[Entity] '.' type=[EntityAttribute]
> ;

> 2) What are the right locations to provide such functionality


> Couldy anybody give me a hint?

> TIA

> Martin
Re: XText complex references - how to ...? [message #478071 is a reply to message #468498] Thu, 06 August 2009 07:51 Go to previous messageGo to next message
Martin Kuhn is currently offline Martin KuhnFriend
Messages: 49
Registered: July 2009
Member
Hi Helko,

thank you very much for supporting...

It works great.

With example code it is much easier to get it right :-)
Without examples (and only the reference doc) it is not easy to implement
a little bit trickier stuff.

Best regards,
Martin
Re: XText complex references - how to ...? [message #478099 is a reply to message #478071] Thu, 06 August 2009 08:07 Go to previous message
Helko Glathe is currently offline Helko GlatheFriend
Messages: 55
Registered: July 2009
Member
Hi Martin.

Sounds great.

I agree, yesterday I had a similar problem like yours. But I found an
example via google search that set me on the right track
http://5ise.quanxinquanyi.de/2009/07/27/scoping-with-xtext-t mf/.

Cheers, Helko

Martin Kuhn wrote:

> Hi Helko,

> thank you very much for supporting...

> It works great.

> With example code it is much easier to get it right :-)
> Without examples (and only the reference doc) it is not easy to implement
> a little bit trickier stuff.

> Best regards,
> Martin
Previous Topic:[Xtext] Editor could not be initialized
Next Topic:[XText] covered terminal
Goto Forum:
  


Current Time: Tue Apr 23 08:51:50 GMT 2024

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

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

Back to the top