Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 312433

Summary: [Regression] Resource.save() should not reformat the input
Product: [Modeling] TMF Reporter: Sebastian Zarnekow <sebastian.zarnekow>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: moritz.eysholdt
Version: 1.0.0Flags: sebastian.zarnekow: helios+
Target Milestone: RC1   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Introduce immutable SaveOptions next to Resource in favor of mutable SerializerOptions sebastian.zarnekow: review+

Description Sebastian Zarnekow CLA 2010-05-11 10:22:01 EDT

    
Comment 1 Sebastian Zarnekow CLA 2010-05-11 11:35:22 EDT
Created attachment 167948 [details]
Introduce immutable SaveOptions next to Resource in favor of mutable SerializerOptions

The SerializerOptions are unfortunately mutable and require to handle the options map manually. The patch introduces xtext.resource.SaveOptions next to the XtextResource itself. The SaveOptions are immutable and encapsulate the read and write to the options map including full backwards compatibility. Furthermore there is a clear distinction between builder pattern for the options and the created instance. The SerializerOptions have been marked as deprecated. 

Please review.
Comment 2 Moritz Eysholdt CLA 2010-05-11 11:50:20 EDT
All this effort for immutability? hm, ok.

I'd rather have the Builder implement an opt-out for validation than to implement an opt-in.

People that want formatting will write something like:

SaveOptions.newBuilder().format().getOptions();

However, this will implicitly and unintentionally disable ConcreteSyntaxValidation. So if they stumble into Serializationexceptions they have no could why they are not getting better error messages.

If someone doesn't want ConcreteSyntaxValidation he should need to write something like:

SaveOptions.newBuilder().format().noValidation().getOptions();
Comment 3 Moritz Eysholdt CLA 2010-05-11 11:51:43 EDT
Besides the opt-in issue, the patch looks ok to me.
Comment 4 Sebastian Zarnekow CLA 2010-05-11 11:53:42 EDT
Immutability and encapsulation. Both can be quite handy ;-)

I'll modify the validate() to a noValidation() and commit the patch.
Comment 5 Sebastian Zarnekow CLA 2010-05-11 12:03:59 EDT
Fixed in HEAD.
Comment 6 Karsten Thoms CLA 2017-09-19 15:45:51 EDT
Closing bug which were set to RESOLVED before Eclipse Neon.0.