Bug 202948 - [compare] Please provide an IStorageMerger for Java files
Summary: [compare] Please provide an IStorageMerger for Java files
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2007-09-11 12:01 EDT by Stefan Xenos CLA
Modified: 2007-09-12 08:54 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Xenos CLA 2007-09-11 12:01:56 EDT
When sharing Java files in an SCM system, it is quite common to get conflicts on import statements.

The Eclipse framework for auto-merging uses IStreamMergers registered with the content type. Right now, the most specific stream merger for Java files is the text merger.


ENHANCEMENT REQUEST:

This enhancement requests that JDT provide a more specific IStreamMerger for Java files that has special treatment for imports.


SUGGESTED ALGORITHM:

1. Compute the union of all imports from the left and right.
2. If both sides disagree about the positioning of a particular import, go with the version on the left. Otherwise, use the 
nonconflicting position for the import.
3. If the imports are not syntactitally correct, fall back to a normal text merge.
4. The remainder of the file (the non-imports bit) can be merged using the normal text merge.


This algorithm takes advantage of the fact that the ordering of imports is unimportant. As long as the imports are syntactically correct in both versions of the file, the algorithm should never fail on a conflict due to imports.
Comment 1 Dani Megert CLA 2007-09-11 12:22:54 EDT
Moving to JDT UI. Not sure whether JDT or the Compare owner will provide this.
Comment 2 Michael Valenta CLA 2007-09-11 15:03:16 EDT
It is important to note that it is better to implement and use IStorageMerger from the org.eclipse.team.core plug-in.
Comment 3 Martin Aeschlimann CLA 2007-09-12 03:25:59 EDT
help is welcome here