Community
Participate
Working Groups
I have the following source code: public class AlwaysMoreIndentation { int x = 0;/** * Returns the x. * @return int */ public int getX() { return x; }/** * Sets the x. * @param x The x to set */ public void setX(int x) { this.x = x; } } Format on this yields: public class AlwaysMoreIndentation { int x = 0; /** * Returns the x. * @return int */ public int getX() { return x; } /** * Sets the x. * @param x The x to set */ public void setX(int x) { this.x = x; } } Format a few more times on this yields: public class AlwaysMoreIndentation { int x = 0; /** * Returns the x. * @return int */ public int getX() { return x; } /** * Sets the x. * @param x The x to set */ public void setX(int x) { this.x = x; } } (Each format adds a level of indentation in the method comment, while the member comment has reached a stable state.) Formating a few more times yields: public class AlwaysMoreIndentation { int x = 0; /** * Returns the x. * @return int */ public int getX() { return x; } /** * Sets the x. * @param x The x to set */ public void setX(int x) { this.x = x; } } As a side remark: The entire content of those lines is now beyond colum 80, which is what I have set my maximum line length to. In Window/Preferences/Java/Code Formatter/New Lines, I have none of the checkboxes checked.
I find it difficult to catch my own mistakes in this small Bugzilla editing field... Here is a minor correction. Where I have said: "Each format adds a level of indentation in the method comment, while the member comment has reached a stable state." , I should have said: "Each format adds a level of indentation in the set method comment, while the get method comment has reached a stable state."
Comments should be formatted using spaces, but this seems like a bug.
Actually, I seem to be getting into this mess more frequently than you might think. The following needs further investigation, but I don't have the time to do that investigation right now: This seems to happen when I have more { than } (or the other way around?) in my cu and use "format" to see what is going on. Format is quite useful for that. But in such circumstances, it seems to kill white space between what now isn't the closing "}" of a method and the javadoc comment following it. (Put this into a bug report of its own if you can reproduce and think that's worth it.)
Opening a bug report always worth it. It ensures that a potential problem won't be lost.
We need to clear 2.1 bug reports that won't be addressed before 2.1. The new implementation is still in the works. Therefore we cannot include it for 2.1. Not enough testing and we need to polish the preferences. This will be address for 2.2 as stated in the JDT/Core plan.
Resurrecting for 3.0
does it work now ?
With the new formatter, we return: public class AlwaysMoreIndentation { int x = 0;/** * Returns the x. * @return int */ public int getX() { return x; }/** * Sets the x. * @param x The x to set */ public void setX(int x) { this.x = x; } } If you want the javadoc comment to start on a new line, you have to do it yourself. The new formatter leaves the comments where they are.
Fixed and released. Regression test added.
Javadoc are always moved to a new line.
Verified.
See bug 46717. This could be optional if this is an issue.