Community
Participate
Working Groups
Recently (maybe not?) this changed and I didn't notice it causing my source files to be mixed tabs and spaces. That's really bad. Can the default change back to tabs?
The default comes from J Core. 2.1.3 and older it was a tab and then it was changed to use the built-in 'Java Conventions' profile which uses Spaces. No idea who drove that decision ;-) Olivier, do we plan to provide a 'real' Java Conventions profile with mixed tabs/spaces? Personally I'd like to use tabs as default.
Thanks Daniel. This is a really big one for me, can it get fixed?
Frederic, this seems to be the way to defaults preferences are initialized. Could you please investigate?
Steve - did you define your own custom formatter settings profile ? If not, then it is a consequence of Java conventions becoming closer to official specifications. By default, the mixed tabs and spaces is mandated, and we recently added support for it. Now if you are not using Java conventions, but rather your custom set (or Eclipse 2.1 profile) then you should not be seeing this.
All I know is that since the beginning of time, SWT chose tabs instead of spaces. I don't remember doing anything special to enable this. Everytime I get a new Eclipse, I did nothing and tabs where used. Sometime recently, I got a new Eclipse and spaces were used. The team has been releasing code until I noticed it. Now SWT has code that is mixed, some tab and some spaces (I don't know how much). When the font is changed, we will look like fools in the debugger. If I have this problem, doesn't every other component have it too?
Olivier, this issue seems not to be in 3.1 M5... However, nothing has changed in default. Creating a new workspace and looking immediately at Code Formatter options page always (ie. in both versions) shows 'Java Conventions [built-in]' selected and Use tab character is always unselected... Here's a small scenario to reproduce the problem: 1) create a brand new workspace 2) create a project Test and a class X. 3) Inside class X declaration, hits return and code 'int x;' 4) Then you get: a) with 3.1 M5 --------public class X { -------- int x; --------} b) with 3.1 M6 candidate --------public class X { -------- int x; --------} So it sounds that JDT/Core behaves diffrently since 3.1 M5. I will investigate a little bit more during M7 about this preference issue
This is a different problem. Format the code is the action to do.
Seems not to be a different problem. Format the code provide same results: - tabs for 3.1 M5 - spaces for 3.1 M6
Then we need to find out how the UI is initializing the code formatter preferences in M5.
I think this is related to this inconsistency. We should provide a new profile and the UI should initialize with this new profile. I believe this should fix it. I'll try locally.
I'd like this to be fixed for M6, if in fact is was introduced in M5. This will stop others from getting mixed tabs and spaces in their source code. Thought?
We are working on it.
Thanks.
Changes in: DefaultCodeFormatterConstants.java DefaultCodeFormatterOptions.java JavaCorePreferenceInitializer.java
*** Bug 82275 has been marked as a duplicate of this bug. ***
Steve, when was the last time you changed the eclipse build? This problem is not new.
I have been away on vacation for the last 3 weeks but it could have been around much earlier than that.
Here is the situation. There was a bug in the UI in 3.0 where the UI told us that it was using spaces but really tabs were used. Billy confirmed this. Then sometime between M5 and M6, something was fixed such that M6 now uses spaces and matches the UI. The problem is that changing from tabs to spaces is a big deal and leads to mixed formatting conventions. I suggest that for M6 we put it back to tabs and resolve the issue for M7. That way, people who are using Eclipse won't have the same problem that SWT has (ie. edit and release for a few days, notice that spaces are being used and then have files with mixed tabs and spaces). Adding McQ for his opinion.
My view is this: The default value should remain what it was in M5 (i.e. tabs). If the configuration gui incorrectly displayed the default as use spaces, it should be fixed to indicate that tabs are being used. Doing anything else potentially causes a huge amount of existing code to (unknowingly to the user) be littered with mixed whitespace. This is essentially a breaking change. Whether or not the change would align our code formatter better with Sun's coding conventions, we can not make this kind of change without making the community thoroughly aware of the situation, and getting their buy-in. Given the contentious nature of this issue, please either make Tabs be the default for M6 (and discuss afterwards) or escalate to the PMC.
We will change the Java conventions to use TAB instead of SPACE. This will fix this immediate problem. This will be reviewed post M6 to find a better solution.
JDT/UI has to upgrade the profile version number to make sure that workspaces touched with a misbehaved version of Eclipse will function correctly again.
Verified in I20050331-2000
Unfortunately, the fix we put in makes Steve happen but causes trouble for clients which explicitly choose the Java convention profile. With the fix those user would get tabs again instead of space, which is wrong as well. We tracked down when we have introduced the problem and it went in I20050329-1615. So we propose the following: - to make sure that we don't break clients using M5 or earlier we revert our changes back - we will add a new profile which is called Eclipse. This profile is equal to the Java Convention profile except that it uses tabs instead of spaces. Unfortunately, we can't automatically fix up workspace which where opened using build I20050329-1615 up to I20050331-2000. Those that have used this build and didn't have an own comment formatter profile and therefore relied on the fact that Java conventions is using tabs instead of spaces (as it is defined) will have to switch to the new Eclipse profile manually.
Dirk, can you provide a URL that describes the Java Convention? Thanks.
Here it comes http://java.sun.com/docs/codeconv/. Steve just to clarify. The new profile will give you exactly the same behaviour you had under M5. However, there are rooms for improvements down the road if we can agree on more specific Eclipse coding conventions.
Sounds good.
changes in jdt.ui released > 20050401 Reviewed by Dirk and Tom
Changes reviewed. Looks good. Fixed and released in HEAD.
Verified in I20050401-1205.
The default is spaces again in the latest builds.
not reproducable with I20050426
VI, didn't you see this too?
I saw this with an existing workspace. Tried with a brand new workspace and did not see the problem.
Silly me ... closing.