Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 231845

Summary: [formatter] Javadoc comment formatter should use code 'Blank Lines to Preserve' value at the beginning of <pre>...</pre> tags
Product: [Eclipse Project] JDT Reporter: Frederic Fusier <frederic_fusier>
Component: CoreAssignee: Mateusz Matela <mateusz.matela>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: jerome_lanneluc, mateusz.matela, robert.roth.off
Version: 3.4   
Target Milestone: 4.8 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard: To be verified for 4.8 M5

Description Frederic Fusier CLA 2008-05-13 11:53:45 EDT
Follow-up of bug 231263 review:

org.eclipse.jdt.internal.formatter.Scribe.printJavadocHtmlTag(FormatJavadocText,
FormatJavadocBlock, boolean)
- shouldn't the 'Number of empty lines to preserve' be applied inside a <pre>
tag (instead of applying the 'Remove blank lines' option) ?
Comment 1 Frederic Fusier CLA 2008-05-14 07:15:34 EDT
The real problem is in fact for blank lines at the beginning of the code (e.g. after the <pre> tag and before the first character of the snippet) and at the end of the code (e.g. after the last character of the snippet and before the </pre> tag).

The following example:
interface X01 {
	/**
	 * <pre>
	 * 
	 * 
	 * public class Example {final int a= 1;final boolean b= true;}
	 * 
	 * 
	 * </pre>
	 */
	int foo();
}
is currently formatted as follow with Eclipse built-in:
interface X01 {
	/**
	 * <pre>
	 * 
	 * 
	 * public class Example {
	 * 	final int a = 1;
	 * 	final boolean b = true;
	 * }
	 * 
	 * 
	 * </pre>
	 */
	int foo();
}
(Note that Number of empty lines to preserve = 1 for Eclipse built-in settings)

So, the formatted output should be instead:
interface X01 {
	/**
	 * <pre>
	 * 
	 * public class Example {
	 * 	final int a = 1;
	 * 	final boolean b = true;
	 * }
	 * 
	 * </pre>
	 */
	int foo();
}

Note that in 3.3 the output is:
interface X01 {
	/**
	 * <pre>
	 * public class Example {
	 * 	final int a = 1;
	 * 	final boolean b = true;
	 * }
	 * 
	 * </pre>
	 */
	int foo();
}
Comment 2 Robert Roth CLA 2015-05-02 10:45:26 EDT
On eclipse 4.5M6 I get the correct number of empty lines preserved inside <pre> tags. Do you still see this issue with a recent eclipse version?
Comment 3 Mateusz Matela CLA 2018-01-06 20:33:26 EST
This problem no longer occurs after the formatter redesign.

*** This bug has been marked as a duplicate of bug 303519 ***