Bug 253184 - [save actions][compare] Invoke "Save action" before comparing the files
Summary: [save actions][compare] Invoke "Save action" before comparing the files
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P5 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-03 08:26 EST by Marko Tomljenovic CLA
Modified: 2012-07-27 01:55 EDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marko Tomljenovic CLA 2008-11-03 08:26:55 EST
During our development we often compare local files but also a local file with another version of it (contained in the scm system).

There we often face the problem that the "other" file is e.g. not formatted the as our code.

It would be nice if the "other" file is preformatted before showing it in the compare editor. 
Preferrably the "Save action" shall be applied to the file content before showing it in the compare editor.
Comment 1 Philipe Mulet CLA 2008-11-03 08:44:03 EST
Comparison can be toggled to ignore whitespace differences, which is all formatters are allowed to modify (in theory). 
Is there more you need ?
Comment 2 Marko Tomljenovic CLA 2008-11-03 10:33:29 EST
Formatting is the first step but what would be ideal is to have the same format for e.g.:

- parentheses in conditions
- block syntax of loops/ifs conditions
- "this" qualifier for members
- Class qualifiers for static members

If complete save action would be applied so that the complete file is "transformed" I would get much less diffs than by just ignoring the whitespaces.

Greetings Marko
Comment 3 Tomasz Zarna CLA 2008-11-05 05:42:45 EST
Philippe, I wonder if you know is the "complete save" called for Java Editor somehow different then the one currently available when editing a resource in Compare Editor? In other words, are on-save-actions which could do the formatting available only for Java Editors? If so, this looks like another blocker for bug 169386.
Comment 4 Dani Megert CLA 2012-06-05 02:25:16 EDT
*** Bug 381626 has been marked as a duplicate of this bug. ***
Comment 5 Dani Megert CLA 2012-07-26 02:12:39 EDT
*** Bug 385996 has been marked as a duplicate of this bug. ***
Comment 6 Holger Klene CLA 2012-07-26 14:56:19 EDT
Files on disk / in scm-repository
    1 Read
Display in Compare-Editor
    2 Save
Files on disk

As the duplicate bug has been reopened solely for step 2, lets focus this bug on step 1.

The "Save-Actions" can be seen as a universal code reformat and cleanup filter. Indeed, it would be nice, to apply them on the fly before performing the comparison.

To be more specific, there could be situations, where you selectively apply the filter only to the first or the second file. Especially something like sorting members will perform poorly when it comes to renaming/refactoring methods. If such a "structural" filter is equally applied to both sides, you cannot see if there were additional changes within the method (e.g. recursive calls) or if it was a pure rename.

Moreover I don't see any reason, why to tether this genuine new feature with the existing save-actions for step 2. A default would surely propose to link to them. But this should be overwrite-able the same way, a projects preferences inherit from the workspace settings. If the mechanism is already in place, it would be nice to derive a second layer for specific filter actions per source.

BTW: As we often have a three-way-compare: would it be necessary to also filter the common ancestor?
Comment 7 Dani Megert CLA 2012-07-27 01:55:42 EDT
See also bug 45423.