Monday, September 17, 2012

Eclipse Great Feature: Move Updating References And Commit

Some of the lists in Eclipse allow for bulk operations on them. Find references is one of them.

This allows for the following extremely useful procedure to work: you move and/or rename your Java type definition. This causes uncommitted edits. If you're a mis-en-place, clean, only-does-one-thing-at-a-time operator, you'll just do a commit all to commit these changes. But, if you're like me, you usually discover out-of-place types (classes, interfaces) while working on something else. Anyhow; there may for many possible reasons be uncommitted changes that you're not ready to commit. This makes it difficult to separate the files to commit from the files to keep 'dirty' (let's not consider the case where the same file contains both kinds of changes right now).

That's where for move refactoring operations, the 'Find References' feature will (may?) work fine: the list of found references seems to allow bulk commit. Select all the files you want, and then pop up (left mouse button click or Ctrl-click) the contextual menu. Team > Commit, and you will have your referencing occurrences committed.

This leaves the moved definition file changes, unfortunately. So of course the commit-all is really preferable, if appropriate for your situation.

It would be great if Eclipse would give you an option like: "Would you like to commit all the changes caused by your last action, File moved?".

And if it'd separate relevant changes from irrelevant changes in the same file, that'd be magic.

And if it'd allow selecting actions to commit, from a list of recent actions, that'd be more magic.

Anyway, there is actually a simple two-thirds-of-the-value solution for this: list files in "mtime" (last changed time) order, and allow selecting a range to commit. (Deleted files will be an wrinkle, though.)

I have some more tips on moving files in Eclipse, but they'll have to wait.

So that's that. Consider this a first in a (potential, no promises) series of Eclipse workflow posts. I'd like to know if there are already such things written, so please comment if you know.

No comments:

Post a Comment