Summary: | Java conventions default formatter settings confused | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Tom Hofmann <eclipse> | ||||
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> | ||||
Status: | VERIFIED FIXED | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P3 | CC: | markus.kell.r, philippe_mulet | ||||
Version: | 3.1 | ||||||
Target Milestone: | 3.2 RC1 | ||||||
Hardware: | PC | ||||||
OS: | All | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Tom Hofmann
2005-08-26 04:54:09 EDT
Created attachment 26521 [details]
DefaultCodeFormatterOptions.java.diff
The previous bug fix where we changed this value is bug 104765. The change has not been backported to 3.1.1. According to your comment, the right solution would be: tab_char=MIXED tab_size=8 indent_size=4 tab_char=SPACE tab_size=4 (indent_size=8) // this is not interpreted by the formatter, but the editor uses it as the visual tab length setting, so please set it to 8 doesn't solve anything because the tab is till four characters. So it might look good in Eclipse, but it would be wrong outside of Eclipse in a simple text editor. I checked some code from code librairies and it doesn't seem to follow the Java conventions. Using MIXED as the tab char will end up having tabs and spaces. But it appears that only spaces are using. The conventions themselves don't appear to specify what should be used. From the conventions: "Four spaces should be used as the unit of indentation. The exact construction of the indentation (spaces vs. tabs) is unspecified. Tabs must be set exactly every 8 spaces (not 4)." So the MIXED mode might not be wrong. What do you think? (In reply to comment #2) > tab_char=SPACE > tab_size=4 > (indent_size=8) > > doesn't solve anything because the tab is till four characters. So it might look > good in Eclipse, but it would be wrong outside of Eclipse in a simple text > editor. I don't see how this could be the case - if tab_char is SPACE, it will look good everywhere since the formatter will not insert any tabs! So, code formatted with these settings will look correct in any editor. Of course, to display mixed indents correctly (e.g. rt.jar code), the *editor* still needs to know how to display tabs, but not the *formatter*! What the Java editor does in this case: it uses the indentation_size setting (which is not used by the formatter) to store the visual tab length setting. This is why I asked to set it to 8. (In reply to comment #3) > So the MIXED mode might not be wrong. > What do you think? I agree. The conventions do not specify either mode, so either of the combinations correctly implements the Java conventions. tab_char=MIXED tab_size=8 indent_size=4 This seems to be the best solution for me. Unfortunately this is not backward compatible with the existing Java conventions. But sine we have an Eclipse profile that is the default profile, we might want to change it in the Java conventions. The indent_size to 8 seems to be wrong even if this is what the editor is using. Do you want this to be fixed for 3.2? (In reply to comment #6) > Do you want this to be fixed for 3.2? (sorry for the late answer) Yes please - the settings from your comment 5 are fine for me. would be nice for 3.2! So compare to existing settings. This simply means to change the tab char from SPACE to MIXED. Tom, Do you have any tests that rely on the old settings? I am running all our tests. (In reply to comment #10) > Tom, > > Do you have any tests that rely on the old settings? I don't expect any problems as we normally use eclipse settings or custom ones with INDENT_CHAR=SPACE. I am running the tests with the modifications right now, though. Fixed and released in HEAD. +1 for 3.2RC1 Verified for 3.2 RC1 using build I20060413-0010 |