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 Faupel
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 Dietrich
Messages: 6382
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
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 Faupel
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 message
rafael lima is currently offline rafael lima
Messages: 2
Registered: July 2012
Junior Member
Thank you very much! This also was useful for my project.
Previous Topic:Customizing error messages
Next Topic:Possible Unicode Bug - Greek Polytonic
Goto Forum:
  


Current Time: Tue Oct 21 16:53:32 GMT 2014

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

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