Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xtext]Cross reference between different files
[Xtext]Cross reference between different files [message #665716] Fri, 15 April 2011 15:15 Go to next message
mina  is currently offline mina Friend
Messages: 10
Registered: March 2011
Junior Member
Hi,

I made my grammar with Xtext and it contains cross-references between elements.

At this time, if an element is define in a file, I can refer it in a different file.

I want to restrict cross-referencing to only element present in the same file.

I hope I was clear.
How can I do that ?
Re: [Xtext]Cross reference between different files [message #665733 is a reply to message #665716] Fri, 15 April 2011 16:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

simple change the globalscopeprovider e.g. by
			// scoping and exporting API
			fragment = scoping.ImportURIScopingFragment {}
			// fragment = exporting.SimpleNamesFragment {}

			// scoping and exporting API 
			//fragment = scoping.ImportNamespacesScopingFragment {}
			fragment = exporting.QualifiedNamesFragment {}
			fragment = builder.BuilderIntegrationFragment {}


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xtext]Cross reference between different files [message #665750 is a reply to message #665716] Fri, 15 April 2011 17:56 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

the default infrastructure in Xtext is such that it allows easy cross referencing across file borders. I guess there are a few possibilities to achieve "local referencing only". You could adapt the scoping, navigate your model and provide only the elements that should be visible. You could enable ImportUriScoping as Christian suggested. The global scope provider (the one responsible for making "external" elements visible will then look for imported models (but if there is no language concept for imports, nothing will be visibla), Also, you could bind a completely different IGlobalScopeProvider that always returns a IScope.NULLSCOPE (there is nothing visible from the outer world.)

Alex
Re: [Xtext]Cross reference between different files [message #1508379 is a reply to message #665750] Fri, 12 December 2014 11:01 Go to previous messageGo to next message
Puneet Patwari is currently offline Puneet PatwariFriend
Messages: 64
Registered: November 2014
Member
Hi

This is a relatively old post but very much similar to a current problem. I understand exactly what christian and Alexander is saying but I have a little different requirement. I want my cross references to be visible to my current file as well as the importedNamespace in the file. I don't want the other files to contribute cross-references if they are not listed as "import statements" in my concerned file. I am not working with import URI but only import Namespace.

Thanks in advance.

Regards
Puneet
Re: [Xtext]Cross reference between different files [message #1508384 is a reply to message #1508379] Fri, 12 December 2014 11:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi,

this works if you do not have simple names? or you want to import simple names as well ?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xtext]Cross reference between different files [message #1508516 is a reply to message #1508384] Fri, 12 December 2014 13:34 Go to previous messageGo to next message
Puneet Patwari is currently offline Puneet PatwariFriend
Messages: 64
Registered: November 2014
Member
Hi christian

Actually I think I have framed my question non-clearly. For example, I have 3 model files(A,B,C) of the same grammar. In the 1st File A I have a cross-reference. Now content assist provides me with all the suitable candidates from the other 2 files also, irrespective of my specific import statement ( importedNamespace way not importURI ) in A which points to File B, only. Firstly, What I want is, to restrict the content assist in File A to show options from itself and File B and not from file C, as it is not required in the context of file A. Secondly, if the user wants to point to a particular attribute in File C without importing it, he can do that using FullyQualifiedNaming convention like we do in JAVA, directly. So, my concern is not with the second point , as it is working properly, but with the first.
Do you think I should be customizing the ContentAssistProvider or the ScopeProvider to restrict exposure? Hope I am able to explain my requirement.

By the way what did you mean by "you want to import simple names as well" ? Sorry I did not get you. Sad

Regards
Puneet
Re: [Xtext]Cross reference between different files [message #1508526 is a reply to message #1508516] Fri, 12 December 2014 13:42 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
i still dont get your question

so you want to write

import SomeElement
....

use SomeElement


instead of simply using

use SomeElement


right?

you have to adapt ImportedNamespaceAwareLocalScopeProvider. have a look what ImportScope does.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 12 December 2014 13:44]

Report message to a moderator

Previous Topic:Adding comments during serialization (without Node model)
Next Topic:How to get Ecore ResourceSet from a custom View?
Goto Forum:
  


Current Time: Fri Apr 19 03:18:57 GMT 2024

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

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

Back to the top