[XCore] Referning to <Package>Package.Literals.<Class-Reference> [message #899316] |
Tue, 31 July 2012 13:06 |
Christoph Zwicker Messages: 16 Registered: April 2010 |
Junior Member |
|
|
Hi,
I'm investigating moving custom implementations for derived references to XCore. An example:
class Body {
refers local readonly transient volatile derived Header header
get {
val IScopeProvider provider = ...; // some utility
val IScope scope = provider.getScope(this, <XyzPackage.Literals.BODY__HEADER>)
...
}
}
How can I write the <XyzPackage.Literals.BODY__HEADER> part without having to resort to referencing the generated code? The reason I cannot do that is that our meta model plug-in is separated from the ones the code is generated to and cannot have dependencies on those (anyhow, it would be very unclean to have dependencies from meta model layer to the generated artifacts).
Thanks,
Chris
|
|
|
Re: [XCore] Referning to <Package>Package.Literals.<Class-Reference> [message #899430 is a reply to message #899316] |
Tue, 31 July 2012 19:00 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Christoph,
Comments below.
On 31/07/2012 3:06 PM, Christoph Zwicker wrote:
> Hi,
>
> I'm investigating moving custom implementations for derived references
> to XCore. An example:
>
>
> class Body {
> refers local readonly transient volatile derived Header header
> get {
> val IScopeProvider provider = ...; // some utility
> val IScope scope = provider.getScope(this,
> <XyzPackage.Literals.BODY__HEADER>)
> ...
> }
> }
>
>
> How can I write the <XyzPackage.Literals.BODY__HEADER> part without
> having to resort to referencing the generated code?
Everything within a block is Xbase and it can only refer to Java things,
though often Java things that are inferred from models. Is the problem
just that you need to be using "::" for static references, not "."?
I.e., the inferrer knows that XyzPackage::Literals::BODY__HEADER is valid...
> The reason I cannot do that is that our meta model plug-in is
> separated from the ones the code is generated to and cannot have
> dependencies on those (anyhow, it would be very unclean to have
> dependencies from meta model layer to the generated artifacts).
The inferrer knows what will be generated, so that should be sufficient.
>
> Thanks,
> Chris
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: [XCore] Referning to &lt;Package&gt;Package.Literals.&lt;Class-Reference [message #899490 is a reply to message #899444] |
Wed, 01 August 2012 07:22 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Christoph,
Comments below.
On 31/07/2012 11:01 PM, Christoph Zwicker wrote:
> Ed, thanks for your answer.
>
> The thing is that XyzPackage::eINSTANCE.getBody_Header is not accepted
> in XCore ("Instance access to static member getBody_Header"), while
> PlsqlPackage::getPlSqlBody_Header, which is accepted in XCore,
> generates XyzPackage.getBody_Header() in Java, which of course does
> not compile ("Cannot make a static reference to the non-static method
> getBody_Header() from the type XyzPackage").
Looking at XcoreJvmInferrer I see that we're incorrectly inferring it as
a static method; please open a bugzilla.
>
> Access to inner classes / interfaces is supported by "$", e.g. I can
> actually access XyzPackage$Literals.BODY__HEADER. I can thus get the
> generator to produce the necessary code. This is not offered by
> content assist, though.
This would be the most efficient code compared to the above.
The Xtext guys mentioned that during the next release they'll look at
getting "." working for this purpose in Xbase. Xcore doesn't have any
specialized content assist for this so I'll have to rely on this being
supported by Xbase.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.05846 seconds