Bug 229580 - [formatter] <code> tag should not be considered as immutable
Summary: [formatter] <code> tag should not be considered as immutable
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P5 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-30 05:19 EDT by Frederic Fusier CLA
Modified: 2020-01-02 03:08 EST (History)
2 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-30 05:19:47 EDT
I guess this problem exists since a long while as it was implemented like this in the code when comments formatting moved from JDT/Text to JDT/Core.

The formatter consider 'code' tag as immutable which means that all the text located inside <code>...</code> is not formatted at all: all spaces between words are preserved and the text is not cut when it is over the max length line.

However, looking at Javadoc tool behavior, it does not seem correct. While generating following example:

public class X {

	/**
	 * <p>
	 * Text <code>immutable
     * 		tag                 written			on
     * 		several              lines      and	which 
     *      length is over the max length line specified in the preferences (e.g. 80 characters for Eclipse default build-in)</code>		End
	 */
	void foo() {
	}
}

I got the following text in the generated X.html file:

void foo()

    Text immutable tag written on several lines and which length is over the max length line specified in the preferences (e.g. 80 characters for Eclipse default build-in) End 

Note that the text inside the 'code' tag is displayed using the 'courier' font and the rest of the text is displayed with default browser font. Note also that the line is not cut, if I enlarged my window, I can see all the text on only one line!

So, it sounds that we need to change this behavior on the javadoc formatter to be closer than the Javadoc formatting or add a preference to let user decide what to do in this case...
Comment 1 Frederic Fusier CLA 2008-05-16 06:47:06 EDT
Note that the new comments formatter behaves differently than 3.3 when <pre> section is written inside a <code> section. Although the 3.3 comments formatter considers <code> section as immutable it formats the text contains in the <pre> section.

As an example of this difference, the following test case using
Eclipse built-in + 'Maximum line width for comments' = 40:
public class X01 {

	/**
	 * <code><pre>public class X {}</pre></code>
	 */
	void foo() {
	}
}

is formatted in 3.3 as:
public class X01 {

	/**
	 * <code><pre>
	 * public class X {
	 * }
	 * </pre></code>
	 */
	void foo() {
	}
}

and is unchanged in 3.4RC1 considering that <code> is an immutable section, hence does not format anything between the <code>...</code> tags.
Comment 2 Frederic Fusier CLA 2008-05-27 13:12:51 EDT
Note also that following test case:
public class X02 {

        /**
         * Example of 'code' tag nested inside 'pre' tag:
         * <pre><code>public class X {}</code></pre>
         */
        void foo() {
        }
}

is formatted as follow by the 3.4 formatter:
public class X02 {

	/**
	 * Example of 'code' tag nested
	 * inside 'pre' tag:
	 * 
	 * <pre>
	 * &lt;code&gt;public class X {}&lt;/code&gt;
	 * </pre>
	 */
	void foo() {
	}
}

This seems to be wrong as:
1) the 3.3 formats it as:
public class X02 {

	/**
	 * Example of 'code' tag nested
	 * inside 'pre' tag:
	 * 
	 * <pre><code>
	 * public class X {
	 * }
	 * </code></pre>
	 */
	void foo() {
	}
}
2) Is generated by the javadoc tool as if there will be only a 'pre' tag

In fact, as the <code> tag is not considered as immutable by the javadoc tool, in as soon as a 'pre' tag is present, it obfuscates the 'code' tag if there's one before or after it...
Comment 3 Eclipse Genie CLA 2020-01-02 03:08:49 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.