Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Is there an easy way to mass refactor packages?
Is there an easy way to mass refactor packages? [message #1369752] Tue, 20 May 2014 18:33 Go to next message
Jeff Falkenham is currently offline Jeff FalkenhamFriend
Messages: 13
Registered: May 2014
Junior Member
So I used to be a Java Master. Then I didn't touch it for like 2 or more years.

So I'm going through the tutorials, trying to actually keep proper notes this time, and trying to pick up new features and things I may have never known about because I never needed to use them (eg: while the "basic" tutorials are boring, they do have neat tidbits of information I never knew about, such as putting underscores in numeric literals: long creditCard = 1234_1234_1234_1234;).

And as the breadth of information increases, I want to keep my sample code more organized, so I need more packages:

http://i.imgur.com/80lTuJT.jpg

I want to move all 5 of my packages into the first.languagebasics package.

So "controlflow" becomes "first.languagebasics.controlflow", etc...

Is there an easy way to do this? Sure I can manually do it with 5 packages. But what about when my project gets bigger? Can you do mass refactoring of packages, and place them into a new parent?

Current solution: "refactor -> rename" all 5 packages individually.

Wanted solution: "refactor -> rename" or "refactor -> move" all 5 packages at once, in one action instead of 5 actions.

[Updated on: Tue, 20 May 2014 19:07]

Report message to a moderator

Re: Is there an easy way to mass refactor packages? [message #1369794 is a reply to message #1369752] Tue, 20 May 2014 18:56 Go to previous messageGo to next message
Nikolay Metchev is currently offline Nikolay MetchevFriend
Messages: 15
Registered: July 2009
Junior Member
http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fref-menu-refactor.htm&resultof=%22rename%22%20%22renam%22%20%22subpackage%22%20%22subpackag%22%20

Sounds like you need to use the rename refactoring on the top package. Make sure you tick the rename sub packages option.
Re: Is there an easy way to mass refactor packages? [message #1369814 is a reply to message #1369794] Tue, 20 May 2014 19:06 Go to previous messageGo to next message
Jeff Falkenham is currently offline Jeff FalkenhamFriend
Messages: 13
Registered: May 2014
Junior Member
Nikolay Metchev wrote on Tue, 20 May 2014 14:56
http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fref-menu-refactor.htm&resultof=%22rename%22%20%22renam%22%20%22subpackage%22%20%22subpackag%22%20

Sounds like you need to use the rename refactoring on the top package. Make sure you tick the rename sub packages option.


The thing is, though, they aren't subpackages yet. They don't have a top package.

But in order to put them into a new top package, the only way to do so seems to be individually.
Re: Is there an easy way to mass refactor packages? [message #1369850 is a reply to message #1369814] Tue, 20 May 2014 19:27 Go to previous messageGo to next message
Noopur Gupta is currently offline Noopur GuptaFriend
Messages: 58
Registered: December 2012
Member
You can do that from "Navigator" view. Select folders (packages to move) > Right-click > Move...
However, it considers them as just resources and hence the references (import statements etc) are not updated.
Re: Is there an easy way to mass refactor packages? [message #1369869 is a reply to message #1369850] Tue, 20 May 2014 19:39 Go to previous messageGo to next message
Jeff Falkenham is currently offline Jeff FalkenhamFriend
Messages: 13
Registered: May 2014
Junior Member
Noopur Gupta wrote on Tue, 20 May 2014 15:27
You can do that from "Navigator" view. Select folders (packages to move) > Right-click > Move...
However, it considers them as just resources and hence the references (import statements etc) are not updated.


That sounds like more work than "refactor->rename" individually.

Since they don't have a top package until I move them, I don't even have a string of text I can use for a mass "find/replace".
Re: Is there an easy way to mass refactor packages? [message #1370094 is a reply to message #1369869] Tue, 20 May 2014 21:52 Go to previous message
Eclipse UserFriend
Hi,

Try this,

First create the package you want them to go into. After that is done,
then do a select all of the classes you want to move, and then
mouse-button 2, refactor, move to... and select the package to move them
to. That should handle all of them at once.

Rich
Previous Topic:How to get (or set) what a class extends?
Next Topic: JFrame is not accessible due to restriction?
Goto Forum:
  


Current Time: Sat May 25 09:21:41 GMT 2024

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

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

Back to the top