| Summary: | Do not format when format result is worse than original | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Sergey Fukanchik <fukanchik> | ||||||
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||
| Severity: | minor | ||||||||
| Priority: | P3 | CC: | daniel_megert, jarthana, mateusz.matela, remy.suen | ||||||
| Version: | 3.7 | ||||||||
| Target Milestone: | 3.6 | ||||||||
| Hardware: | All | ||||||||
| OS: | All | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
The code formatter does what it's told to. If you don't like the current result you should tweak them. >you should tweak them.
I meant, set the Java > Code Style > Formatter options to your liking.
Hi Dani, Please tell me: 1) How can i using Java > Code Style > Formatter tweak the formatter NOT to format the lines when the result is worse than original and DO format the lines when result is better than original. Thank you in advance for that. 2) Why isn't it the default setting then? (In reply to comment #3) > 1) How can i using Java > Code Style > Formatter tweak the formatter NOT to > format the lines when the result is worse than original and DO format the lines > when result is better than original. I presume you're just joking around considering that "better" or "worse" is entirely subjective and it is impossible for the formatter to decide "hey, this looks good" or "ugh, this looks bad". If you don't like the way it's trying to format something, then try to set the options to your liking. If what you want doesn't appear to be possible, consider opening an enhancement request outlining the new formatter options that you want to have implemented. Hi Remy,
No, it's not about "ugh, this looks bad". Please see my example. What is not clear?
Ok, above i am speaking about the formatting rule "Line Wrapping". I never touched any formatting options so this was produced by default formatting profile.
The intent of line wrapping is to make text more observable by splitting out-of-screen parts of the line on the boundaries of the syntactic elements. The default profile fails to wrap the line example above to make it more observable because the syntactic element "long-long-string" is not splittable for the profile. Instead of logger.info when .info("..") starts at position 7 The Wrapper makes the obvervability worse by splitting the line and adding lots of spaces at the beginning making .info to start at position 9 and thus hiding larger part of the text. So this way "the formatter result is worse than original".
But my bug is more general then just line wrapping. I want to raise attention on all the formatters in this regard.
And why are you guys so fast in resolving bugs as invalid? (In reply to comment #6) > And why are you guys so fast in resolving bugs as invalid? For a start: the given example in comment 0 doesn't even compile (maybe bugzilla did some wrapping?). And then the bug asks to make the formatting not "worse" which - as Remy already pointed out - is very subjective. So, to continue, I suggest you provide an example that compiles (attach a file if bugzilla keeps wrapping the text) and then we can take a look whether the formatted result is OK according to the default formatter settings or not. Created attachment 182892 [details]
The code before formatting
Created attachment 182894 [details]
The code after formatting
Attached examples. Tab size in my eclipse editor is 4. Thanks for the example! I see your point/bug now and it is indeed a bug. This bug (along with several other formatter bugs) got fixed during 3.6. I suggest you upgrade to 3.6.1. @Dani Megert : indeed this was fixed in java editor. But it still remains in c++ editor. I would like to port this to c++ ide. Do you have any pointer on where or what the fix was? The formatter ownership has changed and the codebase in that area itself has changed quite a bit. Not sure Mateusz can help us here, but just in case, copying him. |
Build Identifier: Build id: M20100211-1343 Code formatted shouldn't split the line when result is worse than the original line. Reproducible: Always Steps to Reproduce: logger.info("long-long-longlong-long-longlong-long-longlong-long-longlong-long-longlong-long-longlong-long-longlong-long-long line eventid=" + eventID); shouldn't be formated as: logger .........info("long-long-longlong-long-longlong-long-longlong-long-longlong-long-longlong-long-longlong-long-longlong-long-long line eventid=" ..............+ eventID);