I'm using Eclipse JDT to build a Java refactoring platform, for exploring different refactorings in memory before choosing one and saving it. I can create working copies of the source files and edit them (for example to rename a type, using ASTRewrite), and I also want to rename one or more of the working copies. I'd hoped that the rename would be stored in the working copy's edit buffer somehow, to be applied if I chose to save it, in the same way as the other edits.

However, my attempt to rename a working copy failed, i.e.

ICompilationUnit original = (... find /piffle/Foo.java from the IJavaProject)
ICompilationUnit workingCopy = original.getWorkingCopy(null);
... edit the working copy ...
workingCopy.rename("Baz.java", false, null);

gave error: Java Model Exception: Java Model Status [Operation not supported for specified element type(s):[Working copy] Foo.java [in piffle [in src [in testplugin]]]]

I checked that I can call rename on the original source file; that worked as expected and renamed the file immediately, so I know the rename parameters are ok. Can anyone suggest a way to achieve this rename, without affecting the original file until I commit a working copy?