Using refactoring participants with EMF [message #890314] |
Thu, 21 June 2012 17:21  |
Eclipse User |
|
|
|
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 #890963 is a reply to message #890370] |
Sat, 23 June 2012 11:36  |
Eclipse User |
|
|
|
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!
|
|
|
Powered by
FUDForum. Page generated in 0.11704 seconds