|
|
Re: How to support implicit imports? [message #883072 is a reply to message #882935] |
Thu, 07 June 2012 19:45 |
Jan Koehnlein Messages: 760 Registered: July 2009 Location: Hamburg |
Senior Member |
|
|
If your imports depend on a context object, you have to override
ImportedNamespaceScopeProvider.internalGetImportedNamespaceResolvers(EObject,
boolean)
and add your imports as an ImportNormalizer. The method
createImportedNamespaceResolver(String, boolean) helps you create such
an object. The XtendImportedNamespaceScopeProvider does something similar.
If they are fixed (such as java.lang.* in Java), the hook is
ImportedNamespaceScopeProvider.getImplicitImports(boolean). For an
example, have a look at the XbaseImportedNamespaceScopeProvider.
Don't forget to bind your subclass of the
ImportedNamespaceAwareScopeProviderin the runtime module of your language.
Am 07.06.12 15:52, schrieb Scott Finnie:
> Would appreciate pointers on how to provide implicit imports. For
> example, I can currently write:
>
> Domain Banking {
> Datatype Identifier {}
> Datatype Integer {}
> }
>
> Subsystem Portfolio of domain Banking {
>
> import Banking.*
>
> Class Account {
> number: Identifier {I}
> balance: Integer
> }
> //..etc.
> }
>
> I'd like to remove the need for the explicit 'import' statement and have
> it inferred automatically from the Subsystem declaration.
>
> I'm thinking the answer might be a custom scope provider - possibly
> subtyping ImportedNamespaceAwareLocalScopeProvider? However that doesn't
> look trivial on the face of it so would appreciate any pointers before I
> disappear down a dead end.
>
> Thanks.
>
>
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
---
Get professional support from the Xtext committers at www.typefox.io
|
|
|
Powered by
FUDForum. Page generated in 0.01784 seconds