Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Using refactoring participants with EMF
Using refactoring participants with EMF [message #890314] Thu, 21 June 2012 21:21 Go to next message
Ben Cox is currently offline Ben CoxFriend
Messages: 17
Registered: June 2012
Junior Member
Hi All,

I'm currently writing an LTK refactoring participant that will offer to change an attribute in an XML file inside a project as I rename the project that it's contained in.

In order to be able to do so, I need to come up with a Change, and in particular I think I probably want a TextFileChange to describe that change.

Of course, it's all very well messing around directly with the text, but I already have an EMF model for the XML - it would seem best to proceed through EMF, in case the XML layout changes in future and I need to change not only the model but also the change-producing code. I was wondering if EMF contains any in-built support for integrating with the LTK refactoring framework? I believe not, given my searches, but that would be the easiest way to do it if it existed.

If that's not the case, I think the next best solution would be to read the XML into the model, perform the change on the model, and re-serialize the XML. However, that would require having some in-memory version of the refactored XML text, since the refactoring framework needs to display a preview of the change. Is there a way of serializing a model to an in-memory XML document - such as an IDocument - so I can create the diff?

Many thanks for your help. Any other solutions would be gratefully welcomed!
Re: Using refactoring participants with EMF [message #890370 is a reply to message #890314] Fri, 22 June 2012 07:08 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
EMF Refactor is what you're looking for.
Re: Using refactoring participants with EMF [message #890963 is a reply to message #890370] Sat, 23 June 2012 15:36 Go to previous message
Ben Cox is currently offline Ben CoxFriend
Messages: 17
Registered: June 2012
Junior Member
Unfortunately I don't think it is (though it does look interesting!). I'm looking to refactor an instance of the model (i.e. change an attribute value in my XML), rather than refactor the model itself.

In the meantime, I've discovered the second Resource.save() method, that enables you to write to an OutputStream, instead of to a file - enabling me to keep an in-memory version of the altered XML to use as a preview.

I get that feeling that EMF is not directly LTK-enabled in terms of refactoring model instances. I'm using the solution in my previous paragraph at the moment (not ideal as it can result in some reordering of attributes, for example, that confuse the preview and file history), but let me know if there is a more integrated solution!
Previous Topic:[CDO] Problem with resource after transaction rollback
Next Topic:Contributing extended models in Eclipse and as stand-alone EMF.
Goto Forum:
  


Current Time: Wed Dec 11 19:50:31 GMT 2019

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

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

Back to the top