Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 336235 - [formatter/matcher] Matcher loses track if ParserRule contains only optional tokens
Summary: [formatter/matcher] Matcher loses track if ParserRule contains only optional ...
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 0.8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-03 09:47 EST by Carl Wannheden CLA
Modified: 2017-09-19 17:24 EDT (History)
1 user (show)

See Also:


Attachments
MyDsl.xtext grammar (322 bytes, application/octet-stream)
2011-02-03 09:49 EST, Carl Wannheden CLA
no flags Details
MyDsl format configuration (1.43 KB, application/octet-stream)
2011-02-03 09:49 EST, Carl Wannheden CLA
no flags Details
Example file (39 bytes, application/octet-stream)
2011-02-03 09:50 EST, Carl Wannheden CLA
no flags Details
Graphviz diagram of format configuration (51.30 KB, application/pdf)
2011-02-03 09:51 EST, Carl Wannheden CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Carl Wannheden CLA 2011-02-03 09:47:24 EST
Build Identifier: 20100917-0705

For the attached grammar, format configuration and example the indentation keeps growing without the optional element. With the optional element the formatting works as expected.

Reproducible: Always

Steps to Reproduce:
1.Created MyDsl project with attached grammar and format configuration
2.Format attached example in the MyDsl editor - indent keeps growing
3.Uncomment "init" and format - expected result
Comment 1 Carl Wannheden CLA 2011-02-03 09:49:13 EST
Created attachment 188232 [details]
MyDsl.xtext grammar
Comment 2 Carl Wannheden CLA 2011-02-03 09:49:44 EST
Created attachment 188233 [details]
MyDsl format configuration
Comment 3 Carl Wannheden CLA 2011-02-03 09:50:19 EST
Created attachment 188235 [details]
Example file
Comment 4 Carl Wannheden CLA 2011-02-03 09:51:58 EST
Created attachment 188236 [details]
Graphviz diagram of format configuration
Comment 5 Moritz Eysholdt CLA 2011-02-09 11:46:23 EST
fixed in "master" and "Helios_maintenance".

It turns out that the Matcher "lost track" when there is a parser rule with only optional syntactical elements.

In case you have been accessing internals of Xtext's Matcher directly, there is one method that now has an additional parameter for loop protection:

protected Pair<List<MatcherTransition>, List<MatcherState>> findTransitionPath(MatcherState from, AbstractElement to, boolean returning, boolean canReturn, Set<Pair<Boolean, MatcherState>> visited);
Comment 6 Moritz Eysholdt CLA 2011-02-09 11:48:44 EST
The class I was referring to is org.eclipse.xtext.formatting.impl.ElementMatcherProvider
Comment 7 Karsten Thoms CLA 2017-09-19 17:13:08 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 8 Karsten Thoms CLA 2017-09-19 17:24:36 EDT
Closing all bugs that were set to RESOLVED before Neon.0