| Summary: | [formatter] Code formatter inserts extra blank lines | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Julien Dufour <eclipse> | ||||
| Component: | Core | Assignee: | Mateusz Matela <mateusz.matela> | ||||
| Status: | CLOSED DUPLICATE | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P5 | CC: | mateusz.matela | ||||
| Version: | 3.2 | ||||||
| Target Milestone: | 4.5 | ||||||
| Hardware: | Macintosh | ||||||
| OS: | Mac OS X - Carbon (unsup.) | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Julien Dufour
There is no code formatter changes between RC4 and RC6. Would it be possible to get the code formatter settings and a test case? Thanks. Created attachment 43840 [details]
Formatter settings and test case
- format.xml contains the formatter settings I'm using for the test case.
- step0.java contains the original test case file.
- step1.java contains the result after a first format action on the test case file.
- step2.java contains the result after a second format action on the test case file.
As you can see in the test case files, the first "format" action correctly insert blank lines between the methods of the class. However, a second blank line is also added in the "addValue" method. The second "format" action insert extra blank lines between the methods as well. The next "format" actions leave the code in the same state. Hello I believed I have identified and solved the issue. The incorrect behaviour occurs when setting the indentation policy to "tab only" and enabling indentation of the blank lines (a recently added feature). With those settings, the "org.eclipse.jdt.internal.formatter.Scribe.printIndentationIfNecessary(StringBuffer)" method gets called and wrongly resets the value of the "lastNumberOfNewLines" member of the class (line 1056 and 1069 in Scribe.java of the 3.2 stable build). This value is not reset when setting the other indentation policies and it is clear that the calling "org.eclipse.jdt.internal.formatter.Scribe.getEmptyLines(int)" method does not expect the value to change. Removing those affectations seems to fix the issue. Important: Those methods are dupplicated in the "org.eclipse.jdt.internal.formatter.Scribe2" class which should be fixed in the same way. Best regards Ownership has changed for the formatter, but I surely will not have enough time to fix your bug during the 3.5 development process, hence set its priority to P5. Please provide a patch if you definitely need the bug to be fixed in this version and I'll have a look at it... TIA This problem no longer occurs after the formatter redesign. *** This bug has been marked as a duplicate of bug 303519 *** |