Bug 229107 - [formatter] New comment formatter fails to format correctly when <table ...> tags is used
Summary: [formatter] New comment formatter fails to format correctly when <table ...> ...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.4 M7   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-28 12:08 EDT by Frederic Fusier CLA
Modified: 2008-04-30 05:17 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Fusier CLA 2008-04-28 12:08:41 EDT
I20080427-2000.

The new comment formatter fails to format correctly following test case:

public class X23c {

/**
 * <table border="1" width="80%" cellpadding="5">
 *	  <tr>
 *	    <td width="20%"><code>TypeDeclaration</code></td>
 *	    <td width="50%"><code>modifiers, isInterface, name, superclass,
 *	      superInterfaces<br>
 *		  RELATIVE_ORDER property</code></td>
 *	  </tr>
 * </table>
 */
void foo() {
}
}
Comment 1 Frederic Fusier CLA 2008-04-28 12:10:02 EDT
Problem come from <table> tags which can have attributes (<tr> as well). The new comment format only handles simple tags definition as <name>....</name>.
Comment 2 Frederic Fusier CLA 2008-04-28 12:31:50 EDT
Released for 3.4M7 in HEAD stream.
Comment 3 Kent Johnson CLA 2008-04-29 11:19:57 EDT
Using I20080429-0100, I'm seeing this as the result of formatting the testcase :

class X23c {

	/**
	 * <table border="1" width="80%" cellpadding="5">
	 * <tr>
	 * <td width="20%"><code>TypeDeclaration</code></td>
	 * <td width="50%"><code>modifiers, isInterface, name, superclass,
 *            superInterfaces<br>
 *                RELATIVE_ORDER property</code></td>
	 * </tr>
	 * </table>
	 */
	void foo() {
	}
}

There appears to be a tab missing at the start of the 2 indented lines.
Comment 4 Frederic Fusier CLA 2008-04-29 11:36:49 EDT
I will still want consider this bug as fixed. The real test case was:

public class X23c {

	/**
	 * <table border="1" width="80%" cellpadding="5">
	 *	  <tr>
	 *	    <td width="20%"><code>TypeDeclaration</code></td>
	 *	    <td width="50%"><code>modifiers, isInterface, name, superclass,
	 *	      superInterfaces<br>
	 *		  RELATIVE_ORDER property</code></td>
	 *	  </tr>
	 * </table>
	 */
	void foo() {
	}
}

but I removed indentations to make it easier to read...

If instead I had removed the text which did not fit the bugzilla short line length, then test case would have been:

public class X23c {

	/**
	 * <table border="1" width="80%" cellpadding="5">
	 *	  <tr>
	 *	    <td width="20%"><code>TypeDeclaration</code></td>
	 *	    <td width="50%"><code>modifiers, isInterface, name,
	 *	      superInterfaces<br>
	 *		  RELATIVE_ORDER property</code></td>
	 *	  </tr>
	 * </table>
	 */
	void foo() {
	}
}

Can you test that this test case is OK using I20080429-0100?

If so, I would prefer you close this bug as verified and open a new bug for the remaining problem you see while testing the original test case: lines are not indented inside a immutable html tag (e.g.<code>...</code>)

Thanks
Comment 5 Kent Johnson CLA 2008-04-29 12:01:06 EDT
I tried this case :

class X23c {

        /**
         * <table border="1" width="80%" cellpadding="5">
         *        <tr>
         *          <td width="20%"><code>TypeDeclaration</code></td>
         *          <td width="50%"><code>modifiers, isInterface, name,
         *            superInterfaces<br>
         *                RELATIVE_ORDER property</code></td>
         *        </tr>
         * </table>
         */
        void foo() {
        }
}

and it produces this :

class X23c {

	/**
	 * <table border="1" width="80%" cellpadding="5">
	 * <tr>
	 * <td width="20%"><code>TypeDeclaration</code></td>
	 * <td width="50%"><code>modifiers, isInterface, name,
         *            superInterfaces<br>
         *                RELATIVE_ORDER property</code></td>
	 * </tr>
	 * </table>
	 */
	void foo() {
	}
}

which if your tabs are set to 4 instead of 8 characters doesn't look correct.

I don't think this case is fixed.

The 2 lines inside the multi-line <code> tags should have the same starting indentation as the other lines.
Comment 6 Kent Johnson CLA 2008-04-29 12:03:31 EDT
The actual comment didn't show up too well... I replaced each tab with TAB and left the spaces alone.


TAB/**
TAB * <table border="1" width="80%" cellpadding="5">
TAB * <tr>
TAB * <td width="20%"><code>TypeDeclaration</code></td>
TAB * <td width="50%"><code>modifiers, isInterface, name,
         *            superInterfaces<br>
         *                RELATIVE_ORDER property</code></td>
TAB * </tr>
TAB * </table>
TAB */
Comment 7 Frederic Fusier CLA 2008-04-29 12:30:55 EDT
Comment 5:
The output is correct: <code>...</code> is considered as immutable, hence we do not touch even the space/tabs at the beginning of the javadoc line (i.e. after the '*').

Comment 6:
This is the same issue than the original test case. The indentation before the beginning of the javadoc line is not well computed inside a <code>..</code> and will be fixed with the other bug...

Still consider this bug fix: the new formatter now can handle correctly <table>, <tr> and <td> html tags. Just remove the immutable <code> tags from the example and you'll see it works well
Comment 8 Kent Johnson CLA 2008-04-29 12:43:33 EDT
I don't agree. I don't see how we can say this is fixed. Not a single case looks correct.


Why don't you remove all leading '*' from the comment and format, then put them back in correctly.
Comment 9 Frederic Fusier CLA 2008-04-30 03:28:26 EDT
(In reply to comment #8)
> I don't agree. I don't see how we can say this is fixed. Not a single case
> looks correct.
> 
As I said the output you showed in comment 5 *is* correct. I will repeat myself, but we do not want to move the line inside the tag <code> as it's immutable

Note that I didn't put a test case in my comment 7, but I guess I should do to show that the new formatter works properly now whith tables tags:

public class X23d {

        /**
         * <table border="1" width="80%" cellpadding="5">
         *        <tr>
         *          <td width="20%">first column</td>
         *          <td width="50%">second column</td>
         *        </tr>
         * </table>
         */
        void foo() {
        }
}

which is correctly formatted as:

public class X23d {

	/**
	 * /**
	 * <table border="1" width="80%" cellpadding="5">
	 * <tr>
	 * <td width="20%">first column</td>
	 * <td width="50%">second column</td>
	 * </tr>
	 * </table>
	 */
	void foo() {
	}
}

> 
> Why don't you remove all leading '*' from the comment and format, then put them
> back in correctly.
> 
That's what I plan to do... But it's an other separated issue: the new formatter does not indent correctly the start of the javadoc lines inside a tag <code>

I'm not trying to reject the other issue, I just want to close this bug and work on the other as soon as you'll open it...
 
Comment 10 Frederic Fusier CLA 2008-04-30 03:30:48 EDT
Sorry, wrong copy/paste on the formatted output (I'm not lucky with examples on this bug...). The correct formatted output is:

public class X23 {

	/**
	 * <table border="1" width="80%" cellpadding="5">
	 * <tr>
	 * <td width="20%">first column</td>
	 * <td width="50%">second column</td>
	 * </tr>
	 * </table>
	 */
	void foo() {
	}
}
Comment 11 Frederic Fusier CLA 2008-04-30 04:33:54 EDT
I've opened  bug 229569 for the line indentation issue.
Comment 12 Jerome Lanneluc CLA 2008-04-30 05:17:44 EDT
The confusion came from the fact that the original test case in comment 0 didn't reflect exactly the bug. This bug is not about the formatting of "<code>...</code>". It is about the formatting of "<table ...>". 

Thus the test case should have been:

public class X23d {

        /**
         * <table border="1" width="80%" cellpadding="5">
         *        <tr>
         *          <td width="20%">first column</td>
         *          <td width="50%">second column</td>
         *        </tr>
         * </table>
         */
        void foo() {
        }
}

The formatting of "<code>...</code>" is still problematic and this is reflected in bug 229569.

I verified that the formatting of the above test case is now correct with I20080429-0100.