Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Cross reference is being activated without an import, why ?
Cross reference is being activated without an import, why ? [message #895077] Wed, 11 July 2012 15:42 Go to next message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
Registered: July 2009
Senior Member
Hi,

I've create a little default model to play with cross references, without change mwe2.

But I'm getting a strange behavior. The cross references is being activated without the use of the import rule !

After run, I've create a project, one package and two files. In the second file, without an import statement, I could reference another organization element from the first file:

Organization:{
	code ferrari
	name "Ferrari"
}

----

Organization:{
	code C4Biz
	name "Long name"
	
	Partnerships:{
		Partnership:{
			[b]partner ferrari[/b]
		}
	}
}




could someone explain me why ?

grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Organization:
	//(imports+=ImportNamespace*)?
	'Organization:'
	'{'
 	'code' name=ID
 	'name' longname=STRING
	('description' description=STRING)?
	('Partnerships:' '{' partnerships+=Partnership* '}')?
	'}';

//ImportNamespace:
//	'Import' importedNamespace=FqnWithWildCard
//;


Partnership:
	'Partnership:'
	'{'
	'partner' company=[Organization|Fqn]
	('agreement' agreement=STRING)?
	'}'
;


FqnWithWildCard:
	Fqn ('.' '*')?;

Fqn:
  ValidID (=>'.' ValidID)*;
  
ValidID:
	ID;


thanks,

Cristiano
Re: Cross reference is being activated without an import, why ? [message #895079 is a reply to message #895077] Wed, 11 July 2012 15:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13515
Registered: July 2009
Senior Member
Hi imports is only for shortening names - not for general visibility

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cross reference is being activated without an import, why ? [message #895100 is a reply to message #895079] Wed, 11 July 2012 16:59 Go to previous messageGo to next message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
Registered: July 2009
Senior Member
Hi Christian,

don't know if I understood what you have write... :/

It means that if I had lot of files in the same project and in referenced manifest, all of them will be loaded same time?

About the shortening name, if both files are in the package "companies", wouldn't the content assist put the qualified name instead the single name?

'Cause I'm using this in grammar: 'partner' company=[Organization|Fqn]

I'm getting this: partner ferrari


shouldn't be partner companies.ferrari ?

thanks,

Cristiano
Re: Cross reference is being activated without an import, why ? [message #895106 is a reply to message #895100] Wed, 11 July 2012 17:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13515
Registered: July 2009
Senior Member
Hi

i am saying:

xtext uses the qualified names of things (here Organization) to store them in the index.
the qualified name is by default parentFQN.elementname
since the org has no parent the orgs name is its name => ferrari
(you do not have any packages in your dsl - folder structure does not count (by default))

=> orgs are visible by their simple name and you need no import nor using a fqn to reference it
company=[Organization|Fqn]

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cross reference is being activated without an import, why ? [message #895114 is a reply to message #895106] Wed, 11 July 2012 17:54 Go to previous messageGo to next message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
Registered: July 2009
Senior Member
Hummm, cool. I think I start to understand this subject. Smile

Two more doubts:

- In our company here, normally we have some rules to name attributes: id (auto generated), code (meaningful with no space), name (meaningful with space).
I want to use qualified in our DSL, so name must not have spaces.
Is there a way to custom xtext so it work with 'code' instead 'name' ?


- In the example that I showed, one organization can't be partner of itself. Where should I custom to avoid the self reference ?

thanks a lot,

Cristiano
Re: Cross reference is being activated without an import, why ? [message #895115 is a reply to message #895114] Wed, 11 July 2012 17:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13515
Registered: July 2009
Senior Member
Yes have a look at iqualifiednameprovider

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cross reference is being activated without an import, why ? [message #895313 is a reply to message #895115] Thu, 12 July 2012 12:35 Go to previous message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
Registered: July 2009
Senior Member
Ok Christian,

thanks a lot for the tips.

For those that have the same doubts than I there some good article about iqualifiednameproviders here:

http://christiandietrich.wordpress.com/2011/07/16/iqualifiednameproviders-in-xtext-2-0/

and about Scopes here:

http://blogs.itemis.de/stundzig/archives/773
Previous Topic:xtext, xtend and source generation
Next Topic:How to disable auto activation of content assist
Goto Forum:
  


Current Time: Tue Aug 04 20:54:44 GMT 2020

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

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

Back to the top