Community
Participate
Working Groups
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.
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
Fixed and released in 2.1 stream.
Verified.
The 2.1 compatibility release notes say that these methods have been deleted/deprecated (bug 29176).