| Summary: | [formatter] invalid example code in comments | ||
|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Karsten Thoms <karsten.thoms> |
| Component: | Xtext | Assignee: | Project Inbox <tmf.xtext-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | trivial | ||
| Priority: | P3 | CC: | btickets, moritz.eysholdt |
| Version: | 1.0.1 | ||
| Target Milestone: | --- | ||
| Hardware: | Macintosh | ||
| OS: | Mac OS X | ||
| Whiteboard: | |||
We should also generate the injected field of the language specific grammar access. *** Bug 350776 has been marked as a duplicate of this bug. *** won't fix because it affects the old formatter infrastructure |
In the formatter implementation the following default code is produced: ------------------------------------------- @Override protected void configureFormatting(FormattingConfig c) { // It's usually a good idea to activate the following three statements. // They will add and preserve newlines around comments // c.setLinewrap(0, 1, 2).before(getGrammarAccess().getSL_COMMENTRule()); // c.setLinewrap(0, 1, 2).before(getGrammarAccess().getML_COMMENTRule()); // c.setLinewrap(0, 1, 1).after(getGrammarAccess().getML_COMMENTRule()); } ------------------------------------------- Removing the comments as suggested will lead to non-compilable code, since getGrammarAccess() will return IGrammarAccess and getML_COMMENTRule()) is only valid on the DSL specific GrammarAccess. I suggest to change the code to: ------------------------------------------- @Override protected void configureFormatting(FormattingConfig c) { // It's usually a good idea to activate the following statements. // They will add and preserve newlines around comments // «MyDSL»GrammarAccess g = («MyDSL»GrammarAccess) getGrammarAccess(); // c.setLinewrap(0, 1, 2).before(g.getSL_COMMENTRule()); // c.setLinewrap(0, 1, 2).before(g.getML_COMMENTRule()); // c.setLinewrap(0, 1, 1).after(g.getML_COMMENTRule()); } -------------------------------------------