Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » add certain files to global scope
add certain files to global scope [message #1711168] Tue, 13 October 2015 16:56 Go to next message
Eleanor Richie is currently offline Eleanor RichieFriend
Messages: 125
Registered: August 2014
Senior Member
Hi,
I have a project with multiple files divided on 2 main packages.
I want to limit the scope of these files to see ONLY the files in the same package.
example:
Package1 has file1, file2, file3 and Package2 has file4, file5, file6

Now in the scope, I want the across files for file1 to make it able to see objects in file2 and file3 ONLY. and for file4 to see objects in file5 and file6.

I want to be able to customize the files to be seen (across files) .

Any help please.

Thanks in advance.
Re: add certain files to global scope [message #1711197 is a reply to message #1711168] Wed, 14 October 2015 05:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi what is the criteria for that "to be seen". what is the place to decide. why cant file1 see file4?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: add certain files to global scope [message #1711280 is a reply to message #1711197] Wed, 14 October 2015 14:21 Go to previous messageGo to next message
Eleanor Richie is currently offline Eleanor RichieFriend
Messages: 125
Registered: August 2014
Senior Member
Hi Chris,
file1 can't see file4 because each file is in a different package.
I want them to see each other (i.e we can reference objects from file1 in file4) when I write in file4 a statement that allows files in a specific package to be accessible.

For example
File1 in package = pack1:
{
integer f1 = 10;

function foo (parameters: integer i, j){
i ++;
j= j+2;
}
}
--------------------------------------------------------------------

File4 in package= pack2 (Now it can't see ANYtHING in file1):
{
integer f2=0;
integer f3= 4;
f2 = foo(f2,f3); // ------------> This should give an error bec. foo is in file file1 in another package that is not accessible.

}
-------------------------------------------------------------------------

Now I will modify file4 to make ALL the files in pack1 to be accessible

File4 in package = pack2 will be like this:

{
Add Package pack1; //This will make files in pack1 accessible in pack2
integer f2=0;
integer f3= 4;
f2 = foo(f2,f3); //This will not give an error now

}

[Updated on: Wed, 14 October 2015 14:30]

Report message to a moderator

Re: add certain files to global scope [message #1711300 is a reply to message #1711280] Wed, 14 October 2015 16:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi this is more or less that imported namespace based scoing does by default (depending on how you implement your nameproviders. Simply give the ekenents the name packangename.ekementname

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: add certain files to global scope [message #1711606 is a reply to message #1711300] Sun, 18 October 2015 09:19 Go to previous messageGo to next message
Eleanor Richie is currently offline Eleanor RichieFriend
Messages: 125
Registered: August 2014
Senior Member
Hi Chris,
your solution is valid if the packages are handled by the grammar as a parent container but they are actually handled by the IDE. for example if I want to change the package of a file I have to click on the file in the project browser and choose to change the package. I took a look at the getScope in the global scope provider and tried to check on the package name there but it is not really working fine.
Any help?
Re: add certain files to global scope [message #1711607 is a reply to message #1711606] Sun, 18 October 2015 09:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi you can analyse the uris of the objects eresources in the nameprovider

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: add certain files to global scope [message #1711608 is a reply to message #1711607] Sun, 18 October 2015 09:43 Go to previous messageGo to next message
Eleanor Richie is currently offline Eleanor RichieFriend
Messages: 125
Registered: August 2014
Senior Member
Hi,
I did that and added the name of the package for each object in the files that belonged to this package. Now I have all the qualified names are correct pack1.fun1 , pack2.fun2 ,...etc.
Now for example the problem lies in this, I have package1 that contains file1 with function func1 and package2 that contains file2 with function func2. If i wrote in func2 "packge1.func1()" I found it accepted and func1 is seen in file2!!!!! however it should be seen ONLY if I added a clause that visible the objects in package1 to package2.
Re: add certain files to global scope [message #1711609 is a reply to message #1711608] Sun, 18 October 2015 10:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
then why do you allow qualified names?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: add certain files to global scope [message #1711610 is a reply to message #1711609] Sun, 18 October 2015 10:01 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
p.s: Importnamespaceawarelocalscopeprovider is the place where to digg

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:[Xbase] Scoping for local variables when extending Xbase expressions
Next Topic:Maintaining xtext model backwards compatibility
Goto Forum:
  


Current Time: Thu Apr 25 17:28:33 GMT 2024

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

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

Back to the top