| Summary: | Formatter corrupts code | ||
|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Missing name <spamdaemon> |
| Component: | cdt-editor | Assignee: | Anton Leherbauer <aleherb+eclipse> |
| Status: | RESOLVED FIXED | QA Contact: | Anton Leherbauer <aleherb+eclipse> |
| Severity: | major | ||
| Priority: | P3 | CC: | cdtdoug |
| Version: | 7.0 | ||
| Target Milestone: | 7.0.2 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
Fixed in HEAD and 7.0.2. *** cdt cvs genie on behalf of aleherbau *** Bug 329165 - Formatter corrupts code [*] CodeFormatterVisitor.java 1.78.2.4 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java?root=Tools_Project&r1=1.78.2.3&r2=1.78.2.4 [*] CodeFormatterTest.java 1.54.2.4 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java?root=Tools_Project&r1=1.54.2.3&r2=1.54.2.4 [*] CodeFormatterTest.java 1.60 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java?root=Tools_Project&r1=1.59&r2=1.60 [*] CodeFormatterVisitor.java 1.85 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java?root=Tools_Project&r1=1.84&r2=1.85 |
Build Identifier: 20100917-0705 Under certain conditions, the formatter breaks the code because it merges preprocessing tokens that should not be merged. This source file is not properly formatted (yes, I know the code is technically invalid). //#define throws /* */ struct Foo { void foo() const throws { } void bar() const throws { } }; Once I press CTRL-SHIFT-F this is the code that results: //#define throws /* */ struct Foo { void foo() constthrows { } void bar() const throws { } }; This would not be such a big problem if this would only break with invalid code. But it also break for me when I define "throws" in some include file. For some reason, it is indexed properly, but the formatter behaves as if the "throws" was not defined. I think this is a serious bug because it generates invalid code. Reproducible: Always Steps to Reproduce: See detail description.