Bug 52921 - [formatting] Javadoc formatting: extra newline with [pre]
Summary: [formatting] Javadoc formatting: extra newline with [pre]
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 normal with 5 votes (vote)
Target Milestone: 3.1 RC3   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 62052 63408 66649 68967 69243 69313 69712 70447 71459 76053 76438 76542 78002 87418 91231 101213 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-02-24 07:15 EST by Fabrizio Giustina CLA
Modified: 2005-06-22 06:09 EDT (History)
24 users (show)

See Also:


Attachments
Patch against JavaDocRegion.java (1.01 KB, patch)
2005-06-13 11:29 EDT, Dani Megert CLA
no flags Details | Diff
Improved patch against JavadocRegion.java (1.22 KB, patch)
2005-06-13 13:30 EDT, Dani Megert CLA
no flags Details | Diff
Additional test case for JavaDocTestCase.java (1.76 KB, patch)
2005-06-13 13:31 EDT, Dani Megert CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fabrizio Giustina CLA 2004-02-24 07:15:53 EST
Resubmitting part of bug 52855, marked as duplicate of bug 49686.
Additional newlines with pre tags are not covered by bug 49686.


Build id: 3.0-M7

- an extra newline is appended before a <pre> tag. I think there are no 
configuration options for this like for the "add an empty line before 
parameters", so it should not be added.



public class WrappingTest
{
    /**
     * Javadocs formatting adds an extra empty line for a [pre] tag like in 
this situation
     * 
     * <pre>wrap here</pre>.
     */
    public static final String CONSTANT3 = "somevalue";

}
Comment 1 Dani Megert CLA 2004-05-13 05:58:11 EDT
*** Bug 62052 has been marked as a duplicate of this bug. ***
Comment 2 Gunnar Wagenknecht CLA 2004-05-14 05:49:19 EDT
I20040512

Note that the extra lines and spaces are added on each run. Thus, if you format 
your class several 6 times you will have 6 empty lines between pre tags and the 
text and 6 additional spaces between the begin of the text and the '*'

Comment 3 Dani Megert CLA 2004-05-21 10:11:04 EDT
*** Bug 63408 has been marked as a duplicate of this bug. ***
Comment 4 Richard Anderson CLA 2004-05-28 03:48:13 EDT
This is a squirrely bug: using the M9 build on the Javadoc below, there is no 
newline added to the first or second <pre> block, but newlines are added to 
the third and fourth <pre> blocks.  As before, one additional newline is added 
to each <pre> block every time the formatter runs.

Also, although "Format HTML tags" is disabled, the formatter puts a newline 
before the closing </pre> tag, which doesn't seem correct or desireable.

/**
 * Weighted or unweighted least-squares line fit. <code>LineFit</code> uses
 * the method of least squares to fit a line to two-dimensional data:
 * 
 * <pre>
 * y = a + b * x </pre>
 * 
 * (This is also called linear regression.) In addition to the slope and
 * y-intercept, <code>LineFit</code> can compute the square of the correlation
 * coefficient (R squared), the Durbin-Watson statistic, the mean squared 
error,
 * sigma, the t-statistics, the predicted y values and the residuals of the y
 * values. <br><br>
 * 
 * <code>LineFit</code> accepts float or double input. If weights are passed
 * to the constructor, <code>LineFit</code> minimizes the weighted sum of the
 * squared errors and applies the weights to the following statistics: R
 * squared, the Durbin-Watson statistic, the mean squared error, sigma and the
 * t-statistics. <br><br>
 * 
 * The decision to use or not use weighting could be made using your a priori
 * knowledge of the data or using supplemental data. If the data is sparse or
 * contains non-random noise, weighting can degrade the solution. Weighting is 
a
 * good option if some points are suspect or less relevant (e.g., older terms 
in
 * a time series, points that are known to have more noise). <br><br>
 * 
 * SYNOPSIS
 * 
 * <pre>
 * try {
 *   LineFit lineFit = new LineFit(x, y, w);
 *   double slope = lineFit.getSlope();
 *   double intercept = lineFit.getIntercept();
 *   double durbinWatson = lineFit.getDurbinWatson();
 *   double meanSqError = lineFit.getMeanSqError();
 *   double rSquared = lineFit.getRSquared();
 *   double sigma = lineFit.getSigma();
 *   double tStatisticSlope = lineFit.getTStatisticSlope();
 *   double tStatisticIntercept = lineFit.getTStatisticIntercept();
 *   double[] predictedYs = lineFit.getPredictedYs();
 *   double[] residuals = lineFit.getResiduals();
 * } catch (IllegalArgumentException exception) {
 *   exception.printStackTrace();
 * } catch (AssertionError error) {
 *   error.printStackTrace();
 * } </pre>
 * 
 * ALGORITHM <br><br>
 * 
 * The least-square line is the line that minimizes the sum of the squares of
 * the y residuals:
 * 
 * <pre>
 *   Minimize SUM((y[i] - (a + b * x[i])) ** 2) </pre>
 * 
 * Setting the partial derivatives of a and b to zero yields a solution that 
can
 * be expressed in terms of the means, variances and covariances of x and y:
 * 
 * <pre>
 *   b = SUM((x[i] - meanX) * (y[i] - meanY)) / SUM((x[i] - meanX) ** 2)
 *             
 *   a = meanY - b * meanX </pre>
 * 
 * Note that a and b are undefined if the x values are all equal. <br><br>
 * 
 */
Comment 5 Dani Megert CLA 2004-06-15 03:18:53 EDT
*** Bug 66649 has been marked as a duplicate of this bug. ***
Comment 6 Rafael Chaves CLA 2004-06-30 10:09:02 EDT
*** Bug 68967 has been marked as a duplicate of this bug. ***
Comment 7 Rafael Chaves CLA 2004-07-05 10:55:10 EDT
*** Bug 69243 has been marked as a duplicate of this bug. ***
Comment 8 Dani Megert CLA 2004-07-06 06:35:43 EDT
*** Bug 69313 has been marked as a duplicate of this bug. ***
Comment 9 Dani Megert CLA 2004-07-12 06:00:08 EDT
*** Bug 69712 has been marked as a duplicate of this bug. ***
Comment 10 Dani Megert CLA 2004-07-22 10:45:38 EDT
*** Bug 70447 has been marked as a duplicate of this bug. ***
Comment 11 Dani Megert CLA 2004-08-05 10:03:21 EDT
*** Bug 71459 has been marked as a duplicate of this bug. ***
Comment 12 David Biesack CLA 2004-08-06 09:18:07 EDT
The formatter is also inserting additional indentation.
For example, before formatting:

/**
 * Pop up a periodic reminder. Usage:
 * 
 * <pre>
 * java org.biesack.simplereminder.Reminder Some text to include in the reminder.
 * java org.biesack.simplereminder.Reminder -t &quot;Remember to stretch.&quot;
-i 1 -s 15 Some text to include in the reminder.
 * </pre>
 * ...
 */

then after formatting the source three times:

/**
 * Pop up a periodic reminder. Usage:
 * 
 * <pre>
 * 
 *  
 *   
 *    java org.biesack.simplereminder.Reminder Some text to include in the reminder.
 *    java org.biesack.simplereminder.Reminder -t &quot;Remember to
stretch.&quot; -i 1 -s 15 Some text to include in the reminder.
 *    
 *   
 *  
 * </pre>
Comment 13 Mazen Faraj CLA 2004-09-01 18:40:37 EDT
just my two cents....
I just opened the formatting preferences, went to the comments tab, 
selected "Clear blank lines in comments", saved and exited. 
Tried formatting again, and no new lines where added !!
went back and de-selected that same option, just trying stuff, formatting now 
_still_ does not generate new lines ! :-( so I honestly dont know how the 
problem disappeared, but Im reporting anyway.

Comment 14 Dani Megert CLA 2004-10-12 02:53:39 EDT
*** Bug 76053 has been marked as a duplicate of this bug. ***
Comment 15 Dani Megert CLA 2004-10-18 05:05:01 EDT
*** Bug 76438 has been marked as a duplicate of this bug. ***
Comment 16 Dani Megert CLA 2004-10-19 10:43:40 EDT
*** Bug 76542 has been marked as a duplicate of this bug. ***
Comment 17 Dani Megert CLA 2004-11-08 06:07:42 EST
*** Bug 78002 has been marked as a duplicate of this bug. ***
Comment 18 Olaf Bigalk CLA 2004-11-12 09:09:04 EST
I am using 

Eclipse Version: 3.1.0
Build id: 200408122000 

and this bug is still present.
Which plug is has to be updated/patched and where can I get it?

I think it is still a bug even though there is the work around to check "Clear 
blank lines in comments" in the Code formater prefereces.
Comment 19 Ulrich Voigt CLA 2004-12-21 04:08:03 EST
I am using 3.0.1, Build id: 200409161125.
I tried the workaround and checked the 'Clear blank lines in comments' option.
But it doesn't work. Newlines are still appended after the <pre> and before the
</pre> tag.
Comment 20 Claudio Nieder CLA 2005-01-01 15:44:27 EST
I can reproduce this bug in eclipse 3.1M4. The workaround did not help.
Comment 21 Dani Megert CLA 2005-03-10 02:46:03 EST
*** Bug 87418 has been marked as a duplicate of this bug. ***
Comment 22 Andrea Aime CLA 2005-03-29 03:20:27 EST
I don't understand how such a bug has not been resolved in one year... are
javadoc comments not in use at IBM? ;-)
Sorry for sounding harsh, but it's really an annoying bug...
Comment 23 Justin Corpron CLA 2005-03-29 03:34:45 EST
(In reply to comment #22)
> I don't understand how such a bug has not been resolved in one year... are
> javadoc comments not in use at IBM? ;-)
> Sorry for sounding harsh, but it's really an annoying bug...

I am starting to try to locate the source of this bug and fix it. I am annoyed
by it too, IBM focuses mostly on new features. I am not a committer and it has
been very hard to figure out how to even properly debug selected sections of
eclipse. The cvs is very hard to navigate and there are many classes involved
with the code formatter.
Comment 24 Dani Megert CLA 2005-03-29 03:44:01 EST
Please note that the comment formatter has just been pushed down to JDT Core
i.e. you will find the code in plug-in org.eclipse.jdt.core, package
org.eclipse.jdt.internal.formatter.comment.
Comment 25 Andrea Aime CLA 2005-03-29 04:10:59 EST
As far as I can tell the problem arises when the text between 
<pre> and </pre> is not valid java code. Yet, it is not supposed
to be... in my case, the <pre> sections contain a pseudo-graphical
representation of a diagram...
Comment 26 Dani Megert CLA 2005-04-13 04:05:11 EDT
*** Bug 91231 has been marked as a duplicate of this bug. ***
Comment 27 Olivier Thomann CLA 2005-05-24 08:38:35 EDT
*** Bug 96268 has been marked as a duplicate of this bug. ***
Comment 28 Andrea Aime CLA 2005-05-24 08:48:11 EDT
Any hope to see this fixed for Eclipse 3.1? It's quite annoying!
Comment 29 Dani Megert CLA 2005-06-13 11:29:48 EDT
Created attachment 22936 [details]
Patch against JavaDocRegion.java
Comment 30 Dani Megert CLA 2005-06-13 11:31:26 EDT
The fix is trivial. I approve this change for 3.1 RC3.
Comment 31 Philipe Mulet CLA 2005-06-13 11:51:18 EDT
+1 for RC3
Comment 32 Dani Megert CLA 2005-06-13 13:28:44 EDT
There's another problem with the source code formatting inside <pre> for some of
the attached examples the code is shifted to the right upon each format. This is
not related to my patch and is covered in bug 99738.

Comment 33 Dani Megert CLA 2005-06-13 13:30:19 EDT
Created attachment 22947 [details]
Improved patch against JavadocRegion.java
Comment 34 Dani Megert CLA 2005-06-13 13:31:39 EDT
Created attachment 22948 [details]
Additional test case for JavaDocTestCase.java

The existing test cases all pass and I've added a new one for this PR.
Comment 35 Olivier Thomann CLA 2005-06-13 15:13:44 EDT
Fixed and released in HEAD.
Regression test added in
org.eclipse.jdt.core.tests.formatter.comment.JavaDocTestCase.testNoExtraNewlineWithPre1.

The regression test contains a workaround for bug 99738.
Comment 36 David Audel CLA 2005-06-16 13:01:28 EDT
Verified using build N20050616-0010 + JDT Core HEAD.
Comment 37 Dani Megert CLA 2005-06-22 06:09:54 EDT
*** Bug 101213 has been marked as a duplicate of this bug. ***