Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Cross referencing(How do you cross reference objects NOT using the "name" attribute?)
Cross referencing [message #649087] Mon, 17 January 2011 10:27 Go to next message
Eclipse UserFriend
Hi,

I've tried creating a new XText Project using an existing Ecore Model (org.eclipse.e4.ui.model.workbench to be exact) and I've come across a number of issues. Some of them I've been able to solve with some additional help, but there's one particular issue we haven't been able to solve...

I understand that in order to cross-reference objects you need to use the "name" attribute, but in e4 the unique ID's are all "elementId"s. I'm having some trouble trying to figure out a way to cross-reference objects using the "elementId" attribute. XText DOES generate the "elementId" attributes for all Objects, but I just can't reference them unless I use the "name" attribute.

Here is an example:

// Handler requires a reference to a Command Object
Handler returns commands::Handler:
'Handler'
'{'
('elementId' elementId=EString)?
('tags' '{' tags+=EString ( "," tags+=EString)* '}' )?
('contributorURI' contributorURI=EString)?
('contributionURI' contributionURI=EString)?
'command' command=[commands::Command|EString]
('persistedState' '{' persistedState+=StringToStringMap ( "," persistedState+=StringToStringMap)* '}' )?
'}';

// Commands SHOULD be able to be referenced by their unique
// "elementId" attribute, but this doesn't seem to work. I can't
// even assign it a "name" attribute either because Xtext will tell me
// "Cannot find compatible feature name in sealed EClass Command
// from imported package http://...."
Command returns commands::Command:
{commands::Command}
'Command'
//name=EString
//elementId=EString
'{'
('elementId' elementId=EString)?
('tags' '{' tags+=EString ( "," tags+=EString)* '}' )?
('contributorURI' contributorURI=EString)?
('commandName' commandName=EString)?
('description' description=EString)?
('category' category=[commands::Category|EString])?
('parameters' '{' parameters+=CommandParameter ( "," parameters+=CommandParameter)* '}' )?
'}';

If anyone has any idea on how to solve this issue, any insight would be greatly appreciated.

Thanks.

- Jesse
Re: Cross referencing [message #649089 is a reply to message #649087] Mon, 17 January 2011 10:39 Go to previous messageGo to next message
Eclipse UserFriend
Hello Jesse,

just bind your own IQualifiedNameProvider (a subclass of DefaultDeclarativeNameProvider) that returns the elementId as qualifiedName for your object that you try to reference.

~Christian
Re: Cross referencing [message #649122 is a reply to message #649089] Mon, 17 January 2011 14:11 Go to previous message
Eclipse UserFriend
Thank you, Sir!

For anyone else that may run into this issue, this link below describes (in detail) the steps in order to accomplish this.

http://www.eclipse.org/forums/index.php?t=tree&th=166779 &#page_top

Thanks again.

- Jesse
Previous Topic:xtext complete examples including xpand
Next Topic:Creating Ant Build files for Xtext projects
Goto Forum:
  


Current Time: Tue Jul 08 00:55:24 EDT 2025

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

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

Back to the top