Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Refactor a class programatically
Refactor a class programatically [message #197656] Fri, 04 March 2005 15:46 Go to next message
Eclipse UserFriend
I want to be able to refactor a java class programmatically, and this could
consist of both moving the class to a different package and renaming the
class.

I've figured out how to get the ICompilationUnit from the IFile object, and
I see that there is a move function on the ICompilationUnit object.

The first argument is an IJavaElement container, which I assume is the new
package. Do I have to create this package first, or will it be created as
part of the move operation? If I have to create the package first, how do I
do that?
Re: Refactor a class programatically [message #197827 is a reply to message #197656] Mon, 07 March 2005 10:02 Go to previous message
Eclipse UserFriend
Yes, the package fragment has to exist before the move. You can create
it using IPackageFragmentRoot#createPackageFragment(...)

Jerome

Shawn L. Pecze wrote:
> I want to be able to refactor a java class programmatically, and this could
> consist of both moving the class to a different package and renaming the
> class.
>
> I've figured out how to get the ICompilationUnit from the IFile object, and
> I see that there is a move function on the ICompilationUnit object.
>
> The first argument is an IJavaElement container, which I assume is the new
> package. Do I have to create this package first, or will it be created as
> part of the move operation? If I have to create the package first, how do I
> do that?
>
>
Previous Topic:JavaModelUtil.findType(IJavaProject,String) and generic types
Next Topic:Editor tabs nightmare
Goto Forum:
  


Current Time: Sat May 10 14:19:23 EDT 2025

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

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

Back to the top