Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Import And Scoping
Import And Scoping [message #1009014] Thu, 14 February 2013 09:51 Go to next message
Girish Kumar is currently offline Girish KumarFriend
Messages: 26
Registered: May 2011
Junior Member
Hi,

I got a scenario, which i feel its a quite a generic feature, that xtext should provide.

A.mydsl has some types defined.

B.mydsl extends A.mydsl using importuri feature(we can say it is nothing but include)
So i am able to get to use the types that are defined in A.mydsl and B.mydsl in B.mydsl.
This is perfect as expected.

Now lets Assume, we have C.mydsl extends B.mydsl , But here i get to use types that are defined in B.mydsl and C.mydsl. I am not getting the types that are defined in A.mydsl.

Is there a way that we can achieve without adding the extra import.

Regards
Girish Kumar V
Re: Import And Scoping [message #1009018 is a reply to message #1009014] Thu, 14 February 2013 09:57 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1159
Registered: July 2009
Senior Member
Hi,

imports are not transitive by default. You will have to provide this functionality yourself (e.g. via implicit imports).

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Import And Scoping [message #1009033 is a reply to message #1009018] Thu, 14 February 2013 10:17 Go to previous messageGo to next message
Girish Kumar is currently offline Girish KumarFriend
Messages: 26
Registered: May 2011
Junior Member
Implicit imports will definitely work, but is there way we can make it transitive, without adding explicitly imports, as in mycase it represents subclass nature.

If it would have been some thing like A is included in B, so in that case in C, explicit import was required
Re: Import And Scoping [message #1009065 is a reply to message #1009033] Thu, 14 February 2013 11:18 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1159
Registered: July 2009
Senior Member
I don't quite understand your question. At some point you have to declare the import. Either the user does it in the model file, or the scoping mechanism adds the import implicitly. I talked about the second option.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Import And Scoping [message #1009078 is a reply to message #1009065] Thu, 14 February 2013 11:44 Go to previous messageGo to next message
Girish Kumar is currently offline Girish KumarFriend
Messages: 26
Registered: May 2011
Junior Member
for Ex : A.java has getABC() API
B.java extends A.java can use the getABC() API
C.java extends B.java and still can use getABC() without importing the A.java.

I know this is not possible by default mechanism,so i needed help to achieve this but not without asking the user to explicitly mentioning the import.

I just wanted to know, is this possible , atleast by extending the ImportURIScoping???
Re: Import And Scoping [message #1009084 is a reply to message #1009078] Thu, 14 February 2013 11:58 Go to previous message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1159
Registered: July 2009
Senior Member
The comparison with java does not work out!
a) not the file B.java extends the the file A.java, but the class B defined in B.java extends the class A in A.java
b) you don't use an import mechanism in java, but qualified names. The imports are only used to allow short names instead of the fully qualified names.
c) getABC() can be used in C because the scoping walks up the type hierarchy.

a) and b) is exactly what Xtext's qualified name fragment does for you. Resources (model files) export elements under a qualified name, other resources can reference these elements without explicitly having to import the containing files (as needed with the URI import).
c) you'll have to implement yourself using scoping because Xtext does not attach any meaning to a reference defined in the grammar.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Previous Topic:How to replace XtextDocument in the editor with a projection of it
Next Topic:Command line use of Xtext
Goto Forum:
  


Current Time: Sun Nov 23 03:47:35 GMT 2014

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

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