Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Distinguish imported namespaces by file type
Distinguish imported namespaces by file type [message #763272] Fri, 09 December 2011 08:31 Go to next message
Eclipse UserFriend
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 10:00 Go to previous messageGo to next message
Eclipse UserFriend
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 06:36 Go to previous messageGo to next message
Eclipse UserFriend
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 05:12 Go to previous messageGo to next message
Eclipse UserFriend
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 13:19 Go to previous messageGo to next message
Eclipse UserFriend
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 04:39 Go to previous messageGo to next message
Eclipse UserFriend
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 14:01 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

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

Alex
Re: Distinguish imported namespaces by file type [message #768036 is a reply to message #765845] Mon, 19 December 2011 08:13 Go to previous message
Eclipse UserFriend
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: Sat Jul 19 07:05:22 EDT 2025

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

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

Back to the top