Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 329996 - [formatter] invalid example code in comments
Summary: [formatter] invalid example code in comments
Status: CLOSED WONTFIX
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 1.0.1   Edit
Hardware: Macintosh Mac OS X
: P3 trivial (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 350776 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-11-11 09:00 EST by Karsten Thoms CLA
Modified: 2016-07-21 04:53 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 Karsten Thoms CLA 2010-11-11 09:00:09 EST
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());
	}
-------------------------------------------
Comment 1 Sven Efftinge CLA 2012-11-19 08:41:31 EST
We should also generate the injected field of the language specific grammar access.
Comment 2 Sven Efftinge CLA 2012-11-21 09:27:07 EST
*** Bug 350776 has been marked as a duplicate of this bug. ***
Comment 3 Moritz Eysholdt CLA 2016-07-21 04:53:18 EDT
won't fix because it affects the old formatter infrastructure