Skip to main content



      Home
Home » Modeling » TMF (Xtext) » [Xtext]Cross reference between different files
[Xtext]Cross reference between different files [message #665716] Fri, 15 April 2011 11:15 Go to next message
Eclipse UserFriend
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 12:27 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: [Xtext]Cross reference between different files [message #665750 is a reply to message #665716] Fri, 15 April 2011 13:56 Go to previous messageGo to next message
Eclipse UserFriend
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 06:01 Go to previous messageGo to next message
Eclipse UserFriend
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 06:10 Go to previous messageGo to next message
Eclipse UserFriend
hi,

this works if you do not have simple names? or you want to import simple names as well ?
Re: [Xtext]Cross reference between different files [message #1508516 is a reply to message #1508384] Fri, 12 December 2014 08:34 Go to previous messageGo to next message
Eclipse UserFriend
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 08:42 Go to previous message
Eclipse UserFriend
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.

[Updated on: Fri, 12 December 2014 08:44] by 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: Sun Jul 06 20:45:24 EDT 2025

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

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

Back to the top