Bug 25206 - DOM/AST: Statement.setLeadingComment specification is inconsistent with the JLS
Summary: DOM/AST: Statement.setLeadingComment specification is inconsistent with the JLS
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 2.1 M3   Edit
Assignee: Jim des Rivieres CLA
QA Contact:
URL:
Whiteboard:
Keywords: api, readme
Depends on:
Blocks:
 
Reported: 2002-10-22 13:22 EDT by Olivier Thomann CLA
Modified: 2003-02-26 17:37 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2002-10-22 13:22:47 EDT
The JLS specifies that a line comment has to end with a line break. The
specification of the DOM/AST considers as valid a line comment without the
ending line break.
This is related to bug 23096.
Comment 1 Jim des Rivieres CLA 2002-10-22 18:18:07 EDT
The specification Statement.get/setLeadingComment is unclear. The prose
says that the comments contain the comment delimiters, but the examples
show end-of-line comments without line terminators. The 2.0 implementation
did the latter. The JLS clearly states that end-of-line comments include
the line terminator, so it more consistent to include them than to omit
them.

The spec has been clarified to use standard (JLS 3.7) terminology
and state that and end-of-line comment string includes the line
terminator. The implementation has been brought into line with
this revised spec. This is a minor breaking change for clients that
followed the examples. Due to a 2.0 bug in AST.parseCompilationUnit, 
statement nodes never have a leading comment; this means the probability
is low that actual clients will be broken.

This API change should be documented in the 2.1 release notes.

The revised specification for Statement.setLeadingComment now reads:
* Sets or clears the leading comment string. The comment
* string must include the starting and ending comment delimiters,
* and any embedded linebreaks.
*
* A leading comment is a comment that appears before the statement.
* It may be either a traditional comment or an end-of-line comment.
* Traditional comments must begin with "/*, may contain line breaks,
* and must end with "*/. End-of-line comments must begin with "//",
* must end with a line delimiter (as per JLS 3.7), and must not contain
* line breaks.
*
* Examples:
* setLeadingComment("/* traditional comment */");  // correct
* setLeadingComment("missing comment delimiters");  // wrong
* setLeadingComment("/* unterminated traditional comment ");  // wrong
* setLeadingComment("/* broken\n traditional comment */");  // correct
* setLeadingComment("// end-of-line comment\n");  // correct
* setLeadingComment("// end-of-line comment without line terminator");  // 
wrong
* setLeadingComment("// broken\n end-of-line comment\n");  // wrong
Comment 2 Olivier Thomann CLA 2002-10-23 10:30:51 EDT
Fixed and released in 2.1 stream.
Comment 3 David Audel CLA 2002-11-13 09:58:13 EST
Verified.
Comment 4 Jim des Rivieres CLA 2003-02-26 17:37:25 EST
The 2.1 compatibility release notes say that these methods have been 
deleted/deprecated (bug 29176).