Skip to main content



      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 08:16 Go to next message
Eclipse UserFriend
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 03:22] by Moderator

Re: Cannot cross reference element composed of multiple IDs [message #1754415 is a reply to message #1754414] Fri, 17 February 2017 08:34 Go to previous messageGo to next message
Eclipse UserFriend
xxx=[YYYYY] is short for xxx=[YYYYY|ID]

=>

Host:
'host' service = [service::ServiceDeclaration| ServiceName]
;
Re: Cannot cross reference element composed of multiple IDs [message #1754416 is a reply to message #1754415] Fri, 17 February 2017 08:45 Go to previous messageGo to next message
Eclipse UserFriend
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 08:57 Go to previous messageGo to next message
Eclipse UserFriend
Hi Tam,

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

Hops this helps. Tx.
Re: Cannot cross reference element composed of multiple IDs [message #1754438 is a reply to message #1754417] Fri, 17 February 2017 15:02 Go to previous messageGo to next message
Eclipse UserFriend
servicename is a datype rule. you have to copy it
Re: Cannot cross reference element composed of multiple IDs [message #1754553 is a reply to message #1754438] Mon, 20 February 2017 03:21 Go to previous message
Eclipse UserFriend
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:Semantic Highlighting using Xtext 2.11
Next Topic:Problems with AbstractFormatter2 when building with gradle
Goto Forum:
  


Current Time: Thu Jul 24 20:44:09 EDT 2025

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

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

Back to the top