Bug 292615 - [quick fix] Make 'Change package declaration' quick fix a multi-fix
Summary: [quick fix] Make 'Change package declaration' quick fix a multi-fix
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-17 20:33 EDT by Prashant Deva CLA
Modified: 2022-11-23 14:31 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Prashant Deva CLA 2009-10-17 20:33:55 EDT
Many times when I manually copy files from one project that are in package com.c to a package com.b, all the files have compile errors in their package declaration line.

I have to manually go to each file and change the package declaration to reflect the new package.

There needs to be some way to right click on a folder/project/package and say 'correct package declarations' so eclipse will do that for all the files in that package automatically.
Comment 1 Dani Megert CLA 2009-10-19 03:32:15 EDT
There's a quick fix to do this.
Comment 2 Prashant Deva CLA 2009-10-19 03:40:50 EDT
(In reply to comment #1)
> There's a quick fix to do this.
Yes, but it works only on one file, so if i copy 100 files i have to go to each file manually and apply the quick fix 100 times.

there needs to be a way to right click a folder/package and have it done for all the files at once.
Comment 3 Dani Megert CLA 2009-10-19 03:54:44 EDT
Simply move your files in the Package Explorer. This will trigger the move refactoring which automatically updates the package declaration.

We could turn the 'Change package declaration' quick fix into a multi-fix so that all issues can be fixed at once.
Comment 4 Prashant Deva CLA 2009-10-19 04:01:16 EDT
(In reply to comment #3)
> Simply move your files in the Package Explorer. This will trigger the move
> refactoring which automatically updates the package declaration.


The problem is that a lot of times the move refactoring doesnt work due to some reason and fails thus people have to copy manually.

Also if one wants to just copy files from one workspace to another then move refactoring wont work.

There are many other cases when move refactoring is not used/available and manual copy of files is done and thats why this refactoring/fix needs to be available to allow mass copies of files across workspaces/projects/packages.
Comment 5 Dani Megert CLA 2009-10-19 04:07:55 EDT
>The problem is that a lot of times the move refactoring doesnt work due to some
>reason and fails thus people have to copy manually.
It can't fail lots of time otherwise we'd have bugs for it. If you have a case where it fails, then please file a bug report.

>Also if one wants to just copy files from one workspace to another then move
>refactoring wont work.
Right, but if you only copy from workspace A to B then the package structure remains unchanged ;-)
Comment 6 Prashant Deva CLA 2009-10-19 04:14:53 EDT
> >Also if one wants to just copy files from one workspace to another then move
> >refactoring wont work.
> Right, but if you only copy from workspace A to B then the package structure
> remains unchanged ;-)

No, I recently copied a bunch of files in one workspace which were in an altogether different project to a new project with a new structure in workspace B.
The files were copied because there was a complete rewrite in place and we couldnt just use the move refactoring for it. 

Trust me the move refactoring fails quite a bit, almost always on large inter -project moves. You dont see bug reports cause people dont bother to do so.
Comment 7 yash dhawan CLA 2022-11-23 14:31:46 EST
If you are in linux then this can be achieved in a little different way.

You may go to the file directory where the new files needs to be put and use the "sed" command to modify the package declarations of all the respective files in one go.

Consider the following example for reference:
sed -i 's/com.restservice.Model/com.restservice.Model_UPDATE/g' *.java

Hope this saves the effort.