Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » import declaration does not work(cross reference problems)
import declaration does not work [message #1699568] Thu, 25 June 2015 08:07 Go to next message
Jingang Zhou is currently offline Jingang ZhouFriend
Messages: 57
Registered: December 2010
Member
Hi,

My grammar is like:
Model:
   imports += ImportDeclaration*
   entities += Entitiy*;
ImportDeclaration:
   "import" importedNamespace=[Entity|QualifiedName];
Entity:
   "entity" name=ID '{'
         subs+=Entity*
         friends+=Friend*
    '}';
Friend:
   "friend" friend=[Entity|QualifiedName];


which allows me to create files below:
//a.entity
import O
entity A {
    entity B
    friend O.P.Q
}

//b.entity
entity O {
   entity P {
      entity Q {
      }
    }
}


The question is: no matter I declare the "import O" in a.entity, the reference to Q in entity A must be with its full qualified name, is that true?

Thanks advance.
Robin
Re: import declaration does not work [message #1699572 is a reply to message #1699568] Thu, 25 June 2015 08:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
your imports

- are no wildcard imports
- will not be picked up by org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.internalGetImportedNamespaceResolvers(EObject, boolean)
- nor by org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getLocalElementsScope(IScope, EObject, EReference)

=> you should customize internalGetImportedNamespaceResolvers and add a wildcard import there



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: import declaration does not work [message #1699703 is a reply to message #1699572] Fri, 26 June 2015 03:21 Go to previous messageGo to next message
Jingang Zhou is currently offline Jingang ZhouFriend
Messages: 57
Registered: December 2010
Member
Hi Christian,

Why entity A can reference entities O, P, Q without an import declaration (i.e., import O)? How can I restrict it?

Thanks.

Jingang Zhou
Re: import declaration does not work [message #1699704 is a reply to message #1699703] Fri, 26 June 2015 03:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi i dont understand your question, please explain

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: import declaration does not work [message #1699705 is a reply to message #1699704] Fri, 26 June 2015 03:37 Go to previous message
Jingang Zhou is currently offline Jingang ZhouFriend
Messages: 57
Registered: December 2010
Member
Christian Dietrich wrote on Thu, 25 June 2015 23:28
hi i dont understand your question, please explain


Sorry, I made a common-sense mistake. Very Happy

Thanks again.
Previous Topic:Keywords getting noticed where they shouldn't
Next Topic:Migration from 2.7.3 to 2.8.3
Goto Forum:
  


Current Time: Fri Apr 19 02:23:24 GMT 2024

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

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

Back to the top