Bug 22073 - Each "format" adds one more level of indentation.
Summary: Each "format" adds one more level of indentation.
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.0 M5   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-07-31 08:34 EDT by Andreas Krüger CLA
Modified: 2003-11-20 11:37 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Krüger CLA 2002-07-31 08:34:17 EDT
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.
Comment 1 Andreas Krüger CLA 2002-07-31 08:37:56 EDT
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."



Comment 2 Philipe Mulet CLA 2002-07-31 10:06:51 EDT
Comments should be formatted using spaces, but this seems like a bug.
Comment 3 Andreas Krüger CLA 2002-07-31 10:19:35 EDT
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.)
Comment 4 Olivier Thomann CLA 2002-07-31 11:13:52 EDT
Opening a bug report always worth it. It ensures that a potential problem won't
be lost.
Comment 5 Olivier Thomann CLA 2003-01-15 13:22:58 EST
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.
Comment 6 Philipe Mulet CLA 2003-06-12 06:35:55 EDT
Resurrecting for 3.0
Comment 7 Philipe Mulet CLA 2003-10-30 04:33:12 EST
does it work now ?
Comment 8 Olivier Thomann CLA 2003-10-30 08:31:15 EST
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.
Comment 9 Olivier Thomann CLA 2003-10-30 08:47:17 EST
Fixed and released.
Regression test added.
Comment 10 Olivier Thomann CLA 2003-11-20 11:29:37 EST
Javadoc are always moved to a new line.
Comment 11 David Audel CLA 2003-11-20 11:32:46 EST
Verified.
Comment 12 Olivier Thomann CLA 2003-11-20 11:37:51 EST
See bug 46717. This could be optional if this is an issue.