Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Invoke externally-defined serializer from command handler
Invoke externally-defined serializer from command handler [message #1105973] Tue, 10 September 2013 14:11 Go to next message
Fabian G. is currently offline Fabian G.Friend
Messages: 60
Registered: May 2010
Location: Christchurch (NZ)
Member
Hi,

I have multiple languages (defined in separate plugins, lets says MyDSL1 and MyDSL2) and I would like to call the MyDSL1 serializer from the MyDSL2 plugin.

First I created a custom MyDSL1Serializer that extends the xtext serializer (almost an empty shell with a constructor calling the super constructor) and bind it from the MyDSL2UIModule with a bindMyDSL1Serializer method (effectively called at startup).

Then I tried to inject the MyDSL1Serializer in my handler (eclipse commands AbstractHandler). The injection seems to work since I retrieve the right class, but the Formatter, QualifiedNameProvider and ParseTreeConstructor referenced by this serializer are the ones from the MyDSL2 plugin, so that when the serializer tries to serialize my emf model, it just crashes because the parse tree constructor is the wrong one.

Any hint on having the serializer referencing "its" own formatter, nameprovider, etc? What am I doing wrong?

Thanks in advance,
Fabian
Re: Invoke externally-defined serializer from command handler [message #1105991 is a reply to message #1105973] Tue, 10 September 2013 14:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

did you try to inject a IGlobalServiceProvider
and ask it for a ISerializer?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Invoke externally-defined serializer from command handler [message #1106004 is a reply to message #1105991] Tue, 10 September 2013 14:55 Go to previous message
Fabian G. is currently offline Fabian G.Friend
Messages: 60
Registered: May 2010
Location: Christchurch (NZ)
Member
Hi Christian,

Once again, you saved my day, the serializer now retrieves the right formatters, etc.
Many thanks!

Don't know if this is the best way to do it, but if someone is interested, here the actual code:

myDSLSerializer = serviceProvider.findService(myDSLModelURI, MyDSLSerializer.class);


Fabian
Previous Topic:IXtextModelListener - modelChanged
Next Topic:Some more questions on implementing task tag support
Goto Forum:
  


Current Time: Thu Apr 25 13:48:45 GMT 2024

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

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

Back to the top