Moving/renaming packages "spread" over more than one folder

The folder structure for my source is like this:
src/
com/
mycompany
test/
com/
mycompany
where all my source is under src, and all my units tests are in corresponding packages under test.

I was trying to move a package to another location. For example, I was trying to move "mypackage" from under com.company.package1 to under com.company.package2.

When I tried this, it said it couldn't do it (as documented in the Help - http://www.intellij.com/docs/help/refactoring/movePackage.html, bottom of the page), because the package was "spread" through several folders.

Is there a logical reason why this refactoring cannot be performed? Or is it just something which IDEA doesn't support at the moment?

In this case, I want to move the packages under both root directories. In other cases, I might want to only move the package under one root. Is this logically possible? (This would presumably be more work, as you'd have to change only some of the references to the package).

And what can I practically do in IDEA as it currently in the current (EAP) version to actually achieve this refactoring?

The other more minor point about this error dialog is that it only comes up after you've entered the new parent package, rather than telling you immediately.


For renaming packages, a similar restriction applies, though less stringent (see http://www.intellij.com/docs/help/refactoring/renamePackage.html, bottom of page). In this case, it might also be nice to be able to choose which parts of the package (i.e. under which root directories) get renamed.

2 comments

Calum MacLean wrote:

And what can I practically do in IDEA as it currently in the current (EAP) version to actually achieve this refactoring?


1. Create com.company.package2.mypackage.
2. Select all classes in com.company.package1.mypackage.
3. Move Refactor, selecting com.company.package2.mypackage.
4. Delete com.company.package1.mypackage. This step might not work
though because of the files in the other root.

Ciao,
Gordon

--
Gordon Tyler (Software Developer)
Quest Software <http://java.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: 416-643-4846 | Fax: 416-594-1919

0

Currently it's limitation of IDEA. Although it looks like it's very
important to support this (especially because often tests are placed in
separate source path).
I submitted request
http://www.intellij.net/tracker/idea/viewSCR?publicId=11639 and we plan it
for Aurora.

--
Valentin Kipiatkov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"

"Calum MacLean" <jiveadmin@jetbrains.com> wrote in message
news:47104.1050575200194.JavaMail.jrun@is.intellij.net...

The folder structure for my source is like this:
src/
com/
mycompany
test/
com/
mycompany
where all my source is under src, and all my units tests are in

corresponding packages under test.
>

I was trying to move a package to another location. For example, I was

trying to move "mypackage" from under com.company.package1 to under
com.company.package2.
>

When I tried this, it said it couldn't do it (as documented in the Help -

http://www.intellij.com/docs/help/refactoring/movePackage.html, bottom of
the page), because the package was "spread" through several folders.
>

Is there a logical reason why this refactoring cannot be performed? Or is

it just something which IDEA doesn't support at the moment?
>

In this case, I want to move the packages under both root directories. In

other cases, I might want to only move the package under one root. Is this
logically possible? (This would presumably be more work, as you'd have to
change only some of the references to the package).
>

And what can I practically do in IDEA as it currently in the current (EAP)

version to actually achieve this refactoring?
>

The other more minor point about this error dialog is that it only comes

up after you've entered the new parent package, rather than telling
you immediately.
>
>

For renaming packages, a similar restriction applies, though less

stringent (see
http://www.intellij.com/docs/help/refactoring/renamePackage.html, bottom of
page). In this case, it might also be nice to be able to choose which parts
of the package (i.e. under which root directories) get renamed.


0

Please sign in to leave a comment.