Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Use extension for main JvmModelInferrer(How to create an extension for the main JvmModelInferrer)
Use extension for main JvmModelInferrer [message #1740477] Sun, 14 August 2016 14:27 Go to next message
Oleg Cohen is currently offline Oleg CohenFriend
Messages: 34
Registered: August 2016
Member
Greetings,

Our main JvmModelInferrer class is becoming rather long and I would like to create a number of additional extension classes to delegate infer logic for different elements and types in our model.

I have this class:

class AcmeDslJvmModelInferrer extends AbstractModelInferrer

I created another one:

class TypeXDslJvmModelInferrer extends AbstractModelInferrer

def inferTypeX(TypeX typeX, extension IJvmDeclaredTypeAcceptor acceptor, boolean prelinkingPhase) { ... }

and added this to the AcmeDslJvmModelInferrer class:

@Inject extension TypeXDslJvmModelInferrer typeXDslJvmModelInferrer

The extension is called correctly but when I do:

accept(...) [

typeX.superTypes += ....
]

I get a NullPointerException. Is there a particular way an extension has to be implemented and wired in?

Thank you!
Oleg
Re: Use extension for main JvmModelInferrer [message #1740540 is a reply to message #1740477] Mon, 15 August 2016 14:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
have a look at org.eclipse.xtext.xbase.jvmmodel.AbstractModelInferrer.setContext(Resource)

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Use extension for main JvmModelInferrer [message #1740567 is a reply to message #1740540] Mon, 15 August 2016 18:23 Go to previous messageGo to next message
Oleg Cohen is currently offline Oleg CohenFriend
Messages: 34
Registered: August 2016
Member
Hi Christian,

Thank you for replying. Which component calls this method and how can I actually call it for my extension class?

I would appreciate additional info!

Best,
Oleg
Re: Use extension for main JvmModelInferrer [message #1740570 is a reply to message #1740567] Mon, 15 August 2016 18:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
i assume you have to overide this in your code and to the same for stuff in your extension (init annotationTypesBuilder and typeReferenceBuilder there manually)
(dont know your exact structure, what you try to do is rather ununusal)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Use extension for main JvmModelInferrer [message #1740579 is a reply to message #1740570] Mon, 15 August 2016 19:24 Go to previous messageGo to next message
Oleg Cohen is currently offline Oleg CohenFriend
Messages: 34
Registered: August 2016
Member
Thank you for the suggestion, it worked!

The reason I am trying to split and use extensions is because my JvmModelInferrer class is becoming really large and I would like to split it into multiple files. Is there perhaps a better way to do so?

Thanks,
Oleg

Re: Use extension for main JvmModelInferrer [message #1740580 is a reply to message #1740579] Mon, 15 August 2016 19:26 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Well actually not

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Xtext from ecore
Next Topic:How to change resourceDescriptionStrategy for GenericResourceDescriptionManager
Goto Forum:
  


Current Time: Tue Apr 23 10:29:22 GMT 2024

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

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

Back to the top