Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Cross Reference to nested Elements
Cross Reference to nested Elements [message #879930] Fri, 01 June 2012 06:36 Go to next message
Julian Faupel is currently offline Julian FaupelFriend
Messages: 2
Registered: June 2012
Junior Member
Hi,

i have written the following grammar.

Module:
	'Modul' name=ID
		(forms+=Formular)+
		dependency=Dependency
	'ModulEnde';

Dependency:
	'Ablauf'
		conditions+=Condition+
	'AblaufEnde'
;

Condition:
	(field=[Field]) (type=ConditionType) '->' (targetElement=[FormElement])

;

Formular:
	'Formular' name=ID
		(formlabel=Label)? 
		(elements+=FormElement)*
	'FormularEnde';

FormElement:
	Field | Orgbox;

Orgbox:
	'OrgEinheit' name=ID  
		(label=Label)?
		(elements+=FormElement)*
	'OrgEinheitEnde';

Field:
	'Feld' (type='optional'|'looping')? name=ID ('maps' model=ModelElement)? 
          ...
	'FeldEnde';


My problem is that the rule "Condition" cannot reference to a "Field" or a "FormElement" which is nested in the "Formular" Element.

Any idea how i can solve this problem?
Re: Cross Reference to nested Elements [message #879935 is a reply to message #879930] Fri, 01 June 2012 06:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14729
Registered: July 2009
Senior Member
Hi,

the problem is that xtext by default uses fully qualified names for cross refs
=>

(a) change the grammar to accept fqns
Condition:
	(field=[Field|FQN]) (type=ConditionType) '->' (targetElement=[FormElement|FQN])

;

FQN: ID ("." ID)*;

(b) use a custom IQualifiedNameProvider that gives stuff simple names.

For some basic /advanced reading have a look at http://blogs.itemis.de/stundzig/archives/773

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Cross Reference to nested Elements [message #879938 is a reply to message #879935] Fri, 01 June 2012 06:52 Go to previous messageGo to next message
Julian Faupel is currently offline Julian FaupelFriend
Messages: 2
Registered: June 2012
Junior Member
Thank you very much. That solved it.

Also thanks for the link with the additional information.

Julian
Re: Cross Reference to nested Elements [message #894214 is a reply to message #879930] Sat, 07 July 2012 18:09 Go to previous messageGo to next message
rafael lima is currently offline rafael limaFriend
Messages: 2
Registered: July 2012
Junior Member
Thank you very much! This also was useful for my project.
Re: Cross Reference to nested Elements [message #1757967 is a reply to message #879930] Wed, 22 March 2017 11:26 Go to previous messageGo to next message
Steve Hickman is currently offline Steve HickmanFriend
Messages: 13
Registered: January 2017
Junior Member
The link listed in this post (http://blogs.itemis.de/stundzig/archives/773) is no longer valid. Where can I find this information now?
Re: Cross Reference to nested Elements [message #1757968 is a reply to message #1757967] Wed, 22 March 2017 11:57 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14729
Registered: July 2009
Senior Member
i think it is gone. but you can ask here if you have any questions

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Previous Topic:using reserved keyword in grammar
Next Topic:Using code generation with Xbase, instead of JVMinferrer
Goto Forum:
  


Current Time: Sun Nov 03 03:38:02 GMT 2024

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

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

Back to the top