| Summary: | [Formatter] eliminating trailing white spaces (file) | ||
|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Alexander Nittka <alex> |
| Component: | Xtext | Assignee: | Project Inbox <tmf.xtext-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | carl.wannheden, karsten.thoms, moritz.eysholdt |
| Version: | 1.0.0 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
|
Description
Alexander Nittka
I could think of introducing "artificial" grammar elements for the formatter to allow formatting instructions for the beginning/end of file. Example: c.setNoSpace().after(BEGIN_OF_FILE); c.setNoSpace().between(f.getFooAccess().getBarKeyword(), END_OF_FILE); (In reply to comment #1) Do you mean something like Model: beginning=Beginning greetings+=Greeting* end=End; Beginning hidden(): {Beginning}; End hidden(): {End}; Greeting: 'Hello' name=ID '!'; ? It was a bit surprising to me that the dummy rules without any consumption were valid at all (and seemed to work, as objects of this type were created and had corresponding parser nodes). However, I could not find a set of rules eliminating trailing white spaces and new lines (same as in the original description). Further, would the introduction of these dummy rules work, if no meta model was generated but only an existing one is instantiated? Nonetheless, I think global "trim beginning", "trim end" options would be quite useful. With your proposed approach there might not be a combinatorial explosion, but in case a file can end in many different ways (due to alternatives, optional assignments), there would still be a lot of configuration code. I have a test case which reads and writes an Xtext resource and compares the written file contents to the original source. On serialization the last EOL was dropped. It is expected that the serialized form matches exactly the original input file contents. won't fix because it affects the old formatter infrastructure |