Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Cross Reference without additional feature
Cross Reference without additional feature [message #1761176] Mon, 08 May 2017 15:11 Go to next message
 is currently offline Friend
Messages: 23
Registered: September 2015
Junior Member
Hi, I tried to look for answers on the forum on my own, but didn't find what I've looked for - please don't kill me if the question has been already answered.

I have defined following:

AttributeGroup:
( doc = COMMENT )?
'group' name = ID
'from' mainObject = [ Class | QualifiedName ]
'select' attributes += AbstractAttribute (',' attributes += AbstractAttribute)*;
now I define a reference:

AttributeGroupReference:
group = [AttributeGroup]
;
this is all well, but what I would actually want to do would be to refer the "attributes" feature of the AttributeGroup in moe or less following fashion:

AttributeGroupReference:
group = [AttributeGroup]
attributes = group.attributes;
;
the idea is that I would then be able to access the attributes directly from the AttributeGroupReference (I don't really need the AttributeGroup itself even).

Originally I've posted it on stack overflow (if somebody want's to get some fame ...):
http://stackoverflow.com/questions/43810119/xtext-cross-reference-of-a-feature-of-a-reference
Re: Cross Reference without additional feature [message #1761182 is a reply to message #1761176] Mon, 08 May 2017 15:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14736
Registered: July 2009
Senior Member
Hi I don't understand you question.

What about sharing sample models as well


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Cross Reference without additional feature [message #1761186 is a reply to message #1761182] Mon, 08 May 2017 16:25 Go to previous messageGo to next message
 is currently offline Friend
Messages: 23
Registered: September 2015
Junior Member
Sorry - don't understand what the sample models are Smile - I'm using xtext as a parser and I'm working on the grammar - the only model I know of is created at runtime when I parse the file with my grammar and I suppose it's not the thing you want from me.

Essentially what I want to do is to make a feature that can be fed either by direct definition of a type or by a cross reference to the type defined elsewhere - or to somehow make in one type a cross reference and then to assig a feature from this reference to a feature in my type .
Re: Cross Reference without additional feature [message #1761187 is a reply to message #1761186] Mon, 08 May 2017 16:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14736
Registered: July 2009
Senior Member
yes and in your question you mix grammar and concrete syntax.

so please:

how shall the file look like that the user models
and where shall be the cross references
and where should they point to


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Cross Reference without additional feature [message #1761216 is a reply to message #1761176] Tue, 09 May 2017 06:21 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

I also don't completely get what you mean. I could imagine that you mean that you want to refer to a list of attributes.

Quote:

AttributeGroupReference:
attributes += [AbstractAttribute|QualifiedName]+

;


This would allow to list a set of attributes with their qualified name, which are prefixed with the AttributeGroup's name. Should work out of the box.
Re: Cross Reference without additional feature [message #1761316 is a reply to message #1761216] Tue, 09 May 2017 16:06 Go to previous messageGo to next message
 is currently offline Friend
Messages: 23
Registered: September 2015
Junior Member
This would be almost what I need - except is that I want to define this list of attributes in a different place (the AttributeGroup) and be able to use the whole list, not the attributes in the list one by one.

so I have the "AttributeGroup" that has the list of "AbstractAttribute" named "attributes"
and I want the "AttributeGroupReference" to also have the list of "AbstractAttribute" named "attributes" but the contents of this list to be taken from the referenced "AttributeGroup"
Re: Cross Reference without additional feature [message #1761335 is a reply to message #1761316] Tue, 09 May 2017 18:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14736
Registered: July 2009
Senior Member
that do you mean by use?

cant you simply follow the reference?

e.g.

doSomeThingWith(AttributeGroupReference ref) {
ref.getGroup().getAttributes()
}



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Cross Reference without additional feature [message #1761346 is a reply to message #1761316] Wed, 10 May 2017 06:09 Go to previous message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

I think Christian is right. Since you don't want to list the attributes in the concrete syntax model, you just need to name the AttributeGroup for a cross reference. To get the group's attributes list, just evaluate the collection in the AST.
Previous Topic:Xtext 2.12 and Guava
Next Topic:Compare and merge/mark on Regeneration Xtext-Xtend
Goto Forum:
  


Current Time: Wed Dec 11 10:00:45 GMT 2024

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

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

Back to the top