Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » global scope and importedURI
global scope and importedURI [message #1055460] Wed, 08 May 2013 10:39 Go to next message
Andrea Sindico is currently offline Andrea SindicoFriend
Messages: 266
Registered: November 2010
Senior Member

I am having some troubles in configuring scoping in my DSL

In my mwe2 I have set
 // scoping and exporting API
 fragment = scoping.ImportURIScopingFragment {}
 fragment = exporting.SimpleNamesFragment {}
 


with this configuration the content assist provides all the possible references (those contained in the same file and those contained in different files within the project) despite the import. This means that without any import I still see in the content assist references to elements of the right type but defined into different files.
when I chose one of these references the compiler depicts it as an error "coulnd't resolve reference to.. " although the referenced element is defined into an imported file. Note that the import seembs to be correcty resolved as I don't see any "Imported resource could not be found." error that I would expect as I have also configured

fragment = validation.JavaValidatorFragment {
                    composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
                    composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
                } 


What am I doing wrong?


Follow me on Twitter @andreasindico

Re: global scope and importedURI [message #1057731 is a reply to message #1055460] Wed, 08 May 2013 13:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14667
Registered: July 2009
Senior Member
Hi,

make sure you remove xbasefragment and javatypesfragment as well


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: global scope and importedURI [message #1702913 is a reply to message #1057731] Mon, 27 July 2015 11:05 Go to previous messageGo to next message
anudeep arya is currently offline anudeep aryaFriend
Messages: 49
Registered: March 2013
Member
Hi All,

I have tried the same, but is this scoping enough to validate unique names in files as well as imported files.

Also i want references only from import files and not from all files in the directory or project.

What should i do for it.

Eg:
File A:

import "fileB"
component calculator
{
///Contents of component
]
fileB
component calculator
{
///Contents of component
]

Above configuration doesn't give me any error.Do i have to do anything else for this and also as said before i want references only from imported files.

Please do reply as i am stuck with this issue for the whole day Sad

Regards,
Anudeep.

Re: global scope and importedURI [message #1702914 is a reply to message #1702913] Mon, 27 July 2015 11:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14667
Registered: July 2009
Senior Member
how does your wf look like

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: global scope and importedURI [message #1702915 is a reply to message #1702914] Mon, 27 July 2015 11:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14667
Registered: July 2009
Senior Member
btw from your snippet i do not get your semantics and problem at all

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: global scope and importedURI [message #1702922 is a reply to message #1702915] Mon, 27 July 2015 11:52 Go to previous messageGo to next message
anudeep arya is currently offline anudeep aryaFriend
Messages: 49
Registered: March 2013
Member
Hi Christian,

Thanks for the response,

My mwe file looks like the one below:


fragment = validation.ValidatorFragment auto-inject {
composedCheck ="org.eclipse.xtext.validation.ImportUriValidator"
composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
}
// scoping and exporting API
fragment = scoping.ImportURIScopingFragment auto-inject {}

// fragment = scoping.ImportNamespacesScopingFragment {}
fragment = exporting.SimpleNamesFragment auto-inject {}

Now after i comment out scoping.ImportNamespacesScopingFragment {}
I can only see references from the current and imported files.

But the second problem that is restricting unique "component" name in current and imported files remains
Re: global scope and importedURI [message #1702923 is a reply to message #1702922] Mon, 27 July 2015 11:56 Go to previous messageGo to next message
anudeep arya is currently offline anudeep aryaFriend
Messages: 49
Registered: March 2013
Member
First problem is resolved as in the runtime module the scoping has been changed from defaultglobalscopeprovider to Importuriscopeprovider.
after commenting out scoping.ImportNamespacesScopingFragment {}

I think that is what i need.
Re: global scope and importedURI [message #1702924 is a reply to message #1702923] Mon, 27 July 2015 12:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14667
Registered: July 2009
Senior Member
Hi,

yes and no,

zou should remove xbases typesgenerator and other fragments from the wf as well. then you do not need the extra binding


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: global scope and importedURI [message #1702925 is a reply to message #1702924] Mon, 27 July 2015 12:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14667
Registered: July 2009
Senior Member
what is the unique thing you are talking about

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: global scope and importedURI [message #1702926 is a reply to message #1702925] Mon, 27 July 2015 12:05 Go to previous messageGo to next message
anudeep arya is currently offline anudeep aryaFriend
Messages: 49
Registered: March 2013
Member
Yes i did remove xbases typesgenerator and other fragments from the wf .


My Second question is if i have a file A which imports fileB and contains

Component test{
}

now fileB also contains component with name test

Component test{
}

It should throw an error automatically as NamesAreUniquevalidator is enabled and the scope is at importuri level

But this is not happening.Do i have to do anything extra for that

Re: global scope and importedURI [message #1702930 is a reply to message #1702926] Mon, 27 July 2015 12:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14667
Registered: July 2009
Senior Member
NamesAreUniquevalidator is locally only

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: global scope and importedURI [message #1702932 is a reply to message #1702930] Mon, 27 July 2015 12:23 Go to previous messageGo to next message
anudeep arya is currently offline anudeep aryaFriend
Messages: 49
Registered: March 2013
Member
Then how can unique names scope be increased to imported files.

Do we have to write a custom validationhelper and give it in runtime module ??
Re: global scope and importedURI [message #1702933 is a reply to message #1702932] Mon, 27 July 2015 12:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14667
Registered: July 2009
Senior Member
no

you have to implement that logic completely yourself, by interating the xtext index (eg via IContainer.Managers visible containers + ICOntainer.get...)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: global scope and importedURI [message #1702935 is a reply to message #1702933] Mon, 27 July 2015 12:29 Go to previous message
anudeep arya is currently offline anudeep aryaFriend
Messages: 49
Registered: March 2013
Member
Ohh.ok .fine..I got this.

Thanks so much for the help Christian.
Previous Topic:How to inject a mocked dependency into the tested instance?
Next Topic:Lining up arguments vertically
Goto Forum:
  


Current Time: Fri Apr 26 17:57:54 GMT 2024

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

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

Back to the top