Bug 552035

Summary: Unhelpful org.eclipse.xtext.util.EmfFormatter list index 'stabilization'
Product: [Modeling] TMF Reporter: Ed Willink <ed>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: NEW --- QA Contact:
Severity: minor    
Priority: P3 CC: christian.dietrich.opensource, sebastian.zarnekow
Version: unspecifiedKeywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Windows 10   
Whiteboard:

Description Ed Willink CLA 2019-10-11 07:19:26 EDT
EmfFormatter.printInt can stabilize the length of a formatted Integer, but unhelpfully this is used to stabilize the index of a list entry as in 

FamilyPlanning {
    cref SurnamePlan surnamePlans [
        0 : SurnamePlan {
            attr EString name 'Flanders'


For me, the sole use case of EmfFormatter is its excellent utility for comparing two models in a way that JUnit renders helpfully.

However if a 9-element list is compared with an 11-element list, all entries are reported as different because the "0" index is stabilized as the two digit "1 " to match the max length of any index.

Please remove the stabilization at line 118.

(Also at line 62 "innerIdent" should be "innerIndent").
Comment 1 Christian Dietrich CLA 2019-10-11 07:42:34 EDT
I am not sure if changing this would lead to semantic api changes and thus annoy people but maybe that could be done configurable
Comment 2 Ed Willink CLA 2019-10-11 08:20:56 EDT
Obviously any change is a semantic API breakage; it's just a matter of whether it's reasonable or not.

For the compare-equals use case, it makes no difference since equality of two serializations is unaffected. There is an issue of equality with a saved EmfFormatter serialization, but I have always avoided that since certainly I never regarded EMFFormatter as stable. I always compare EMFFormatter serializations of a new / old Resource not a new / old EMFFormatter serialization.

For the human browsing use case, the change is a fractional improvement, but EmfFormatter is not very good for humans anyway. I find an EMF tree or pure XMI better.

If you have other use cases and they are affected, then WONTFIX. If not it's a minor bug fix.
Comment 3 Sebastian Zarnekow CLA 2019-10-16 06:24:05 EDT
I think it wouldn't do any harm to add an option that allows to disable the padding.