Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 312433 - [Regression] Resource.save() should not reformat the input
Summary: [Regression] Resource.save() should not reformat the input
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 1.0.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: RC1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-11 10:22 EDT by Sebastian Zarnekow CLA
Modified: 2017-09-19 15:45 EDT (History)
1 user (show)

See Also:
sebastian.zarnekow: helios+


Attachments
Introduce immutable SaveOptions next to Resource in favor of mutable SerializerOptions (34.13 KB, patch)
2010-05-11 11:35 EDT, Sebastian Zarnekow CLA
sebastian.zarnekow: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.