Bug 202948

Summary: [compare] Please provide an IStorageMerger for Java files
Product: [Eclipse Project] JDT Reporter: Stefan Xenos <sxenos>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: ASSIGNED --- QA Contact:
Severity: enhancement    
Priority: P3 CC: daniel_megert, jean-michel_lemieux, martinae, Michael.Valenta, ppshah
Version: 3.4Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

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