Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Browse a type passed to AbstractModelInferrer(Or use reflection on a JvmTypeReference)
Browse a type passed to AbstractModelInferrer [message #1220890] Sun, 15 December 2013 16:08 Go to next message
Cioran Naroic is currently offline Cioran NaroicFriend
Messages: 18
Registered: December 2013
Junior Member
Hi everyone,

I'm designing a DSL with Xtext, using an AbstractModelInferrer to map the concepts of my DSL to the Java concepts.

One of my grammar rule looks as follows:
...
EcorePkgDecl:
    'from' pkg = JvmTypeReference
;
...


The classical usage is as follows (somedsl.SomedslPackage is a user package generated by EMF):
...
from somedsl.SomedslPackage
...


In my AbstractModelInferrer, I want to be able to browse (ie. use reflection) on the JvmTypeReference that represents the somedsl.SomedslPackage. My goal is to generate Java interfaces for the package itself and for each EClass contained in the package. I was planning to use reflection on the EPackage to get this information and generate my interfaces.

Unfortunately, I don't see anyway to do that. Maybe I should use another rule in my grammar (something else than JvmTypeReference). Or maybe there's a trick in the AbstractModelInferrer to emulate such behavior.

Thank you for your help Smile
Re: Browse a type passed to AbstractModelInferrer [message #1231555 is a reply to message #1220890] Tue, 14 January 2014 23:52 Go to previous messageGo to next message
Anil Bhatia is currently offline Anil BhatiaFriend
Messages: 23
Registered: February 2011
Junior Member
Were you able to resolve this, and could you please share the solution..?
Re: Browse a type passed to AbstractModelInferrer [message #1231678 is a reply to message #1220890] Wed, 15 January 2014 07:26 Go to previous message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
during 'preIndexingPhase' you are only able to look up types sitting in
upstream projects and jars. If the EPackage is local you won't see it.

And you won't get the java.lang.Class but a JvmGenericType, which will
allow you to inspect it.


Am 16/12/13 20:24, schrieb Cioran Naroic:
> Hi everyone,
>
> I'm designing a DSL with Xtext, using an AbstractModelInferrer to map
> the concepts of my DSL to the Java concepts.
>
> One of my grammar rule looks as follows:
>
> ...
> EcorePkgDecl:
> 'from' pkg = JvmTypeReference
> ;
> ...
>
>
> The classical usage is as follows (somedsl.SomedslPackage is a user
> package generated by EMF):
>
> ...
> from somedsl.SomedslPackage
> ...
>
>
> In my AbstractModelInferrer, I want to be able to browse (ie. use
> reflection) on the JvmTypeReference that represents the
> somedsl.SomedslPackage. My goal is to generate Java interfaces for the
> package itself and for each EClass contained in the package. I was
> planning to use reflection on the EPackage to get this information and
> generate my interfaces.
>
> Unfortunately, I don't see anyway to do that. Maybe I should use another
> rule in my grammar (something else than JvmTypeReference). Or maybe
> there's a trick in the AbstractModelInferrer to emulate such behavior.
>
> Thank you for your help :)


--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
Previous Topic:Access a referenced JvmGenericType in the JvmModelInferrer
Next Topic:Embedded editor and crossreferncing to surounding EMF model
Goto Forum:
  


Current Time: Fri Apr 19 00:11:48 GMT 2024

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

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

Back to the top