Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Import And Scoping
Import And Scoping [message #1009014] Thu, 14 February 2013 04:51 Go to next message
Eclipse UserFriend
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 04:57 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

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

Alex
Re: Import And Scoping [message #1009033 is a reply to message #1009018] Thu, 14 February 2013 05:17 Go to previous messageGo to next message
Eclipse UserFriend
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 06:18 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Import And Scoping [message #1009078 is a reply to message #1009065] Thu, 14 February 2013 06:44 Go to previous messageGo to next message
Eclipse UserFriend
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 06:58 Go to previous message
Eclipse UserFriend
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
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: Wed Jul 23 07:35:30 EDT 2025

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

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

Back to the top