| Summary: | Closing Braces doesn't work with Nested Braces | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Thomas Reisenbichler <thomas.reisenbichler> | ||||
| Component: | Xtext | Assignee: | Hendrik Buender <hendrik.buender> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | major | ||||||
| Priority: | P3 | CC: | christian.dietrich.opensource, karsten.thoms, sven.efftinge | ||||
| Version: | 2.3.1 | Keywords: | triaged | ||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows Server 2008 | ||||||
| See Also: | https://github.com/eclipse/xtext-eclipse/pull/95 | ||||||
| Whiteboard: | v2.11 | ||||||
| Attachments: |
|
||||||
Problem analysis:
When enter is hit the inner start and stop terminal is found correctly, but the MultiLineTerminalsEditStrategy recognizes that the statement is nested and searches for the surrounding start and stop terminal. After the outer start terminal is found correctly, the stop terminal is searched for with the offset of the inner stop terminal + 1. At that offset (after the { and before //) the ITypedRegion is a __sl_comment leading to a search for the closing brace within the following __sl_comment regions. Therefore, the closing brace in the next line is (}!) is not found because it is in the wrong ITypedRegion (__dftl_partition_content_type).
Proposed Problem solution:
Closing tokens can only be in a __dftl_partition_content_type ITypedRegion. Therefore, if the region at inner stop terminal + 1 is not a __dftl_partition_content_type ITypedRegion that region is skipped until a __dftl_partition_content_type is found that is than passed to the DocumentUtil.searchInSamePartition method.
GitHub Pull Request 95 created by [HBuender] https://github.com/eclipse/xtext-eclipse/pull/95 thanks for the contribution! Fixed in Xtext 2.11 |
Created attachment 228666 [details] Sample With following grammar and the given example for the grammar, the MultiLineTerminalsEditStrategy adds a closing brace when hitting enter after "Thomas {". Problem is, that it kind of oversees the closing brace "}//" and then inserts a new brace, which is syntactically incorrect. ======= Grammar ======= Model: greetings+=Greeting*; Greeting: 'Hello' '{' persons+=Person '}' '!'; Person: name=ID '{' birthday=Birthday '}'; Birthday: name=ID; ======= Example ======= Hello { Thomas { Birthday }// } ! Attached is a simple project with the grammar.