Using Eclipse JDT to rename a working copy of a source file
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?
By null_guy in forum Java
Last Post: 07-16-2008, 07:33 AM
By haran415 in forum VB Classic
Last Post: 04-15-2007, 11:40 AM
By priyavenkat in forum VB Classic
Last Post: 08-13-2005, 02:55 PM
By jase_dukerider in forum C++
Last Post: 04-14-2005, 08:48 PM
By T TADCOCK in forum VB Classic
Last Post: 09-23-2000, 01:15 PM
Tags for this Thread
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL