Bug 229954 - [formatter] New comment formatter fails to format correctly when invalid throws reference
Summary: [formatter] New comment formatter fails to format correctly when invalid thro...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.4 RC1   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-02 10:08 EDT by Frederic Fusier CLA
Modified: 2008-05-13 09:22 EDT (History)
3 users (show)

See Also:
jerome_lanneluc: review+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Fusier CLA 2008-05-02 10:08:44 EDT
Using build I20080502-0100.

The new comment formatter wrongly formats the following test case (the line break in the comment is due to bugzilla, the @throws description is on the same line):

public class X {

	/**
	 * @throws import org.eclipse.core.runtime.CoreException if there's a marker problem
	 */
	void foo() {
	}
}

as follow:

public class X {

	/**
	 * @throws org.eclipse.core.runtime.CoreException if there's a marker
	 * 	problem
	 */
	void foo() {
	}
}

Note that the import has disappeared!

Then reformatting twice change again the output to:

public class X {

	/**
	 * @throws org.eclipse.core.runtime.CoreException 
	 * 		if there's a marker problem
	 */
	void foo() {
	}
}

Set as major as the formatter remove some text from the original source...
Comment 1 Frederic Fusier CLA 2008-05-02 10:10:06 EDT
The problem comes from the fact that the reference is invalid (the 'import' keyword). The FormatterCommentParser should handle this case properly...
Comment 2 Frederic Fusier CLA 2008-05-06 05:50:21 EDT
The patch fixing this issue has been attached to bug 230230.
Jerome can you please review?
Comment 3 Frederic Fusier CLA 2008-05-06 07:08:45 EDT
Released for 3.4RC1 in HEAD stream.
Comment 4 Eric Jodet CLA 2008-05-13 06:27:20 EDT
Verified for 3.4RC1 using build I20080510-2000.
Comment 5 Eric Jodet CLA 2008-05-13 06:37:54 EDT
(In reply to comment #4)

question: should the @throws tag behave as the @param tag regarding javadoc formatting preferences?

Using the new formatter (Build id: I20080510-2000):
/**
 * @throws import org.eclipse.core.runtime.CoreException if there's a marker
 * problem
 */

Using the old formatter (Build id: M20070921-1145):
/**
 * @throws import
 *             org.eclipse.core.runtime.CoreException if there's a marker
 *             problem
 */

Note: with the new formatter, no new line is added after the @throws reference,
whereas, with the old formatter, the @throws tag is handled like a @param tag
(this is confirmed by switching corresponding preference: when New line after @param tags preference is disabled, no new line is added when formatting the above javadoc)
Comment 6 Eric Jodet CLA 2008-05-13 09:22:51 EDT
(In reply to comment #5)
discussing this with Frederic, opened a new bug 231796