Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [XCore] Referning to <Package>Package.Literals.<Class-Reference>
[XCore] Referning to <Package>Package.Literals.<Class-Reference> [message #899316] Tue, 31 July 2012 13:06 Go to next message
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 &lt;Package&gt;Package.Literals.&lt;Class-Reference&gt; [message #899430 is a reply to message #899316] Tue, 31 July 2012 19:00 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26088
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
Re: [XCore] Referning to &lt;Package&gt;Package.Literals.&lt;Class-Reference&gt; [message #899444 is a reply to message #899430] Tue, 31 July 2012 21:01 Go to previous messageGo to next message
Christoph Zwicker
Messages: 16
Registered: April 2010
Junior Member
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").

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.
Re: [XCore] Referning to &amp;lt;Package&amp;gt;Package.Literals.&amp;lt;Class-Reference [message #899490 is a reply to message #899444] Wed, 01 August 2012 07:22 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26088
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.
Re: [XCore] Referning to &amp;lt;Package&amp;gt;Package.Literals.&amp;lt;Class-Reference [message #899814 is a reply to message #899490] Thu, 02 August 2012 12:43 Go to previous message
Christoph Zwicker
Messages: 16
Registered: April 2010
Junior Member
Bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=386483
Previous Topic:EMF Validation called 4 times for each binding
Next Topic:Why does EAnnoptation initialization code not set the annotation contents ?
Goto Forum:
  


Current Time: Wed Oct 01 18:29:13 GMT 2014

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

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