Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [SOLVED] Cannot cross reference element composed of multiple IDs
[SOLVED] Cannot cross reference element composed of multiple IDs [message #1754414] Fri, 17 February 2017 13:16 Go to next message
Tam Gom is currently offline Tam GomFriend
Messages: 36
Registered: July 2011
Member
Hi all,

I have two DSLs. In the first, I'm defining services, and in the second I would like to reference them.

The code I intend to achieve looks like this:

service org.myapp.MyService {
    ...
}


The service name is something like a fully qualified name where at least two segments are mandatory.

Here's the relevant part of my grammar:

ServiceName:
	ID ('.' ID)* 
;

ServiceDeclaration:
	 'service' name = ServiceName '{'
    	      ...
  	'}'
;


Now, in the second DSL I would like to create a cross reference to the ServiceDeclaration:

host org.myapp.MyService


The grammar with which I describe this is the following:

Host:
    'host' service = [service::ServiceDeclaration]
;


That being said, I get the following error in my second DSL:

Quote:
Couldn't resolve reference to ContractDeclaration 'org'.


From this it seems only the first segment is getting recognized, but if I write

host org


in my second DSL, the error is still thrown.

Also, if I put the Host definition into my first DSL's grammar, it works fine. Of course doing this is impossible with my requirements.

Does anyone have some insights what's wrong with my grammars and how I could make them work?

Thank you.

[Updated on: Mon, 20 February 2017 08:22]

Report message to a moderator

Re: Cannot cross reference element composed of multiple IDs [message #1754415 is a reply to message #1754414] Fri, 17 February 2017 13:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11084
Registered: July 2009
Senior Member
xxx=[YYYYY] is short for xxx=[YYYYY|ID]

=>

Host:
'host' service = [service::ServiceDeclaration| ServiceName]
;


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Cannot cross reference element composed of multiple IDs [message #1754416 is a reply to message #1754415] Fri, 17 February 2017 13:45 Go to previous messageGo to next message
Tam Gom is currently offline Tam GomFriend
Messages: 36
Registered: July 2011
Member
Hi Christian, thank you for the quick response.

Host:
'host' service = [service::ServiceDeclaration| ServiceName]
;

In this case, ServiceName is part of the other DSL, so it is not recognized in the second with this syntax.

'host' service = [service::ServiceDeclaration| service::ServiceName] -- this doesn't help either.
Re: Cannot cross reference element composed of multiple IDs [message #1754417 is a reply to message #1754416] Fri, 17 February 2017 13:57 Go to previous messageGo to next message
Neeraj Bhusare is currently offline Neeraj BhusareFriend
Messages: 123
Registered: July 2009
Location: India
Senior Member
Hi Tam,

PS - https://christiandietrich.wordpress.com/2012/08/07/xtext-referencing-elements-of-one-dsl-from-another-dsl/

Hops this helps. Tx.


Twitter : @NeerajBhusare
Blog : https://nbhusare.github.io/
Best regards, Neeraj
Re: Cannot cross reference element composed of multiple IDs [message #1754438 is a reply to message #1754417] Fri, 17 February 2017 20:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11084
Registered: July 2009
Senior Member
servicename is a datype rule. you have to copy it

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Cannot cross reference element composed of multiple IDs [message #1754553 is a reply to message #1754438] Mon, 20 February 2017 08:21 Go to previous message
Tam Gom is currently offline Tam GomFriend
Messages: 36
Registered: July 2011
Member
Yes, the ServiceName was missing from my second grammar. It all make sense now that I'm aware of it.

It works now, thank you guys.
Previous Topic:Autocompletion on deployed xtext feature not working
Next Topic:Problems with AbstractFormatter2 when building with gradle
Goto Forum:
  


Current Time: Tue Aug 22 05:36:55 GMT 2017

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

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