Bug 439440 - Serializer ignores Resource SaveOptions
Summary: Serializer ignores Resource SaveOptions
Status: NEW
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.4.0   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks: 564265
  Show dependency tree
 
Reported: 2014-07-11 10:15 EDT by Ed Willink CLA
Modified: 2020-10-05 07:55 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Willink CLA 2014-07-11 10:15:05 EDT
Setting the Resource save options OPTION_LINE_DELIMITER has no effect because

org.eclipse.xtext.serializer.impl.Serializer.serialize(EObject obj, ITokenStream tokenStream, SaveOptions options)

uses only the .isFormatting() aspect of SaveOptions.

Surely at least OPTION_LINE_DELIMITER and OPTION_LINE_WIDTH should be respected?
Comment 1 Moritz Eysholdt CLA 2014-07-11 10:48:00 EDT
Hi Ed,

supporting 
org.eclipse.emf.ecore.resource.Resource.OPTION_LINE_DELIMITER 
may be possible. I wasn't aware of that flag, since it has been introduced recently (EMF 2.9).

I would not want to make use of the constant 
org.eclipse.emf.ecore.xmi.XMLResource.OPTION_LINE_WIDTH
because Xtext has no business with the XMLResource.

Furthermore, line with of is the responsibility of the formatter. We'd have to discuss how the formatter should prioritize save options and formatter preferences.
Comment 2 Ed Willink CLA 2014-07-11 10:59:42 EDT
(In reply to Moritz Eysholdt from comment #1)
> supporting 
> org.eclipse.emf.ecore.resource.Resource.OPTION_LINE_DELIMITER 
> may be possible. I wasn't aware of that flag, since it has been introduced
> recently (EMF 2.9).

It's all part of the catchup to compensate for GIT not handling newlines. We need applications to be able to behave consistently all by themselves. So for my development projects I need \n even though I'm on Windows.
Comment 3 Ed Willink CLA 2015-02-21 05:08:13 EST
Ping!

(In reply to Moritz Eysholdt from comment #1)
> supporting org.eclipse.emf.ecore.resource.Resource.OPTION_LINE_DELIMITER 
> may be possible. I wasn't aware of that flag, since it has been introduced
> recently (EMF 2.9).

EMF 2.9 is no longer recent, particularly given that Xtext 2.8 totally blows away all forward compatibility for users.
Comment 4 Ed Willink CLA 2020-10-05 07:55:23 EDT
Problem for the New DeclarativeFormatter. See Bug 564265

User/app does xtextResource.save(....emfSaveOptions)

which the LazyLinkingResource largely ignores.

Surely the SaveOptions that is constructed from emfSaveOptions should at least provide an ability to access the original options so that the standard line delimiter is accessible and also user-defined options such as tab-width, indentation?

i.e. add an options field with getter and setter to SaveOptions.