Bug 244458 - [clean up] Running save actions on refactor
Summary: [clean up] Running save actions on refactor
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 enhancement with 4 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: fix candidate
Keywords:
: 265576 (view as bug list)
Depends on: 195063
Blocks:
  Show dependency tree
 
Reported: 2008-08-18 13:57 EDT by John Arthorne CLA
Modified: 2010-04-08 05:08 EDT (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Arthorne CLA 2008-08-18 13:57:13 EDT
We are now making regular use of the "save actions" in Equinox to ensure we keep our code formatted and imports organized.  Overall this is working great. The only problem we notice is that when refactoring is used, files can be modified and never "saved", so these save actions never have a chance to run. Since we are no longer in the habit of manually formating and organizing imports, we end up with released code in the repository that doesn't match our conventions.  It would be cool if the "save actions" could also be configured to run at the end of a refactoring on the modified files.
Comment 1 Dani Megert CLA 2008-08-19 02:49:35 EDT
>It would be cool if the "save actions" could also be configured
>to run at the end of a refactoring on the modified files.
Or move the save hook from the editor to file buffers which refactoring uses.

Depending on the outcome of bug 195063 we might be able to do something for 3.5.
Comment 2 Benno Baumgartner CLA 2008-08-19 03:58:15 EDT
Another idea we once had, a long time ago, was to run clean-up on commit. That way you can be sure to have "clean" code in your repository no matter what.
Comment 3 Jeff McAffer CLA 2008-12-29 20:49:44 EST
Any thoughts on this getting fixed for Galileo.  It keeps hitting us as we refactor large swaths of code...
Comment 4 Dani Megert CLA 2009-01-05 05:09:05 EST
>  It keeps hitting us as we refactor large swaths of code...
Just to clarify: I assume you would not only want this when the touched file is in the editor but also when it is not even open in an editor, right?
Comment 5 Dani Megert CLA 2009-02-20 02:33:14 EST
*** Bug 265576 has been marked as a duplicate of this bug. ***
Comment 6 Markus Keller CLA 2009-03-18 09:44:46 EDT
I could probably implement this in the RefactoringStarter (take the Change from the RefactoringWizard, collect affected CUs and run save actions on those) or by adding a special Change object at the end of the refactoring change tree.

There's just one problem I don't have a good solution for, and that's Undo behavior. It's technically not possible to show the changes from the save actions already in the preview, so we would have to run them silently after the refactoring changes have been applied (like on Save in the editor).

Now, if we include the save actions in the compound Undo for the whole refactoring, the user has no way to undo just the save actions (in the editor, the Save command adds 'Undo Save Actions' to the undo stack).
But if we split it up into two undo operations, then this will cause confusion if a user runs a refactoring, invokes Undo, and then is surprised that the refactoring has not been undone (only the save actions have been reverted; to undo the refactoring, Undo needs to be invoked a second time).
Comment 7 Dani Megert CLA 2009-04-24 09:54:18 EDT
No time left but something we should follow up during 3.6.