I’ve added a quickfix option to my DSL in which I want to make some modifications to the document text – including renaming some element. I can change text in that element just fine, but I want to also rename all of its references – i.e. rename refactoring. How do I do that?
Can I somehow trigger the built-in rename refactoring from inside a quickfix? Or alternatively, how do I go over all of the element’s references and change them?
So, I found a way to programmatically trigger a rename refactor. I don’t know if it’s the “proper” way – I guess it isn’t, since I had to add
@SuppressWarnings("restriction")to my code – but it works:So to call this from a quick fix, all you need to do is to get the
EObjectand calculate the new name. If the issue occupies a part of theEObjectitself, the object could be retrieved by:You can get an
IXtextDocumentfrom eitherIssueResolutionAcceptor(which you should have if you’re handling an issue) or fromIModificationContext(which you should have if you’re proposing a change).