Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Distinguish imported namespaces by file type
Distinguish imported namespaces by file type [message #763272] Fri, 09 December 2011 13:31 Go to next message
Torsten Schiefer is currently offline Torsten SchieferFriend
Messages: 26
Registered: December 2011
Junior Member
Hello,

My XText Editor should handle two types of files.
The first one (*.os) imports all known namespaces with "importedNamespace". And it also includes the other files (*.osi) via "importURI". That's no Problem thank's to XText.
But the osi-Files don't have importedNamespaces and importURI, because they use the namespaces of their importing os-file.
My idea is to import all namespaces of the project by default, so I don't get linking errors in these files. More isn't necessary.

I know the approach about Default Imports "Xtext cross references and scoping an overview (Part 3)"
But how can I separate this behavior for two kinds of files?

Thank You
Re: Distinguish imported namespaces by file type [message #763780 is a reply to message #763272] Sat, 10 December 2011 15:00 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

are you aware that you can question each EObject for its eResource and each resource for its URI? The URI should contains the file extension. When adapting the scoping, normally you have the context element at hand.

Alex
Re: Distinguish imported namespaces by file type [message #764538 is a reply to message #763780] Mon, 12 December 2011 11:36 Go to previous messageGo to next message
Torsten Schiefer is currently offline Torsten SchieferFriend
Messages: 26
Registered: December 2011
Junior Member
Hi Alex,
thank you for your reply.

Yes, I'm aware of that.
I have created my own ImportedNamespaceAwareLocalScopeProvider and have bind it in my RuntimeModule.
Of course getImplicitImports(boolean) doesn't get any context. So I overrode the calling method getResourceScope(resource, reference).
It can distinguish if a given resources URI endsWith ".osi" and adds the default namespaces.
But it doesn't get any globalScope, only
WrappingScope -> SelectableBasedScope[] -> NULLSCOPE
, so it can't refer to any global namespace.
Re: Distinguish imported namespaces by file type [message #765044 is a reply to message #764538] Tue, 13 December 2011 10:12 Go to previous messageGo to next message
Torsten Schiefer is currently offline Torsten SchieferFriend
Messages: 26
Registered: December 2011
Junior Member
Has anyone an idea?
I don't want to iterate through my file system! Wink
Re: Distinguish imported namespaces by file type [message #765266 is a reply to message #765044] Tue, 13 December 2011 18:19 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

is overriding getImportedNamespaceResolvers or internalGetImportedNamespaceResolvers not an option for you? They do have a context object. Only because the method is called getImplicitImports it need not be the only hook...

Alex
Re: Distinguish imported namespaces by file type [message #765551 is a reply to message #765266] Wed, 14 December 2011 09:39 Go to previous messageGo to next message
Torsten Schiefer is currently offline Torsten SchieferFriend
Messages: 26
Registered: December 2011
Junior Member
Thank you,

that's a realy elegant solution.
But now I have a problem to get all namespaces of my project. Do I have to find them by myself or is there anywhere a List or Scope of them?
Re: Distinguish imported namespaces by file type [message #765845 is a reply to message #765551] Wed, 14 December 2011 19:01 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

the default approach would be to make this information available in the index, if it's not already there.

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: Distinguish imported namespaces by file type [message #768036 is a reply to message #765845] Mon, 19 December 2011 13:13 Go to previous message
Torsten Schiefer is currently offline Torsten SchieferFriend
Messages: 26
Registered: December 2011
Junior Member
Ok, I have found out how to get this information out of the index.
Very nice. Smile

Thank you
Previous Topic:Duplicate Element Problem
Next Topic:terminal rule interference
Goto Forum:
  


Current Time: Thu Apr 25 05:52:11 GMT 2024

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

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

Back to the top