Bug 10874 - DOM/AST: ClassInstanceCreation contains trailing comment
Summary: DOM/AST: ClassInstanceCreation contains trailing comment
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-06 11:27 EST by Dirk Baeumer CLA
Modified: 2002-03-06 17:12 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 Dirk Baeumer CLA 2002-03-06 11:27:44 EST
Build 20020305

In this example

Inner inner= /*]*/new Inner()/*[*/;

the class instance creation node contains the leading comment. Since it is an 
expression and ends at ) the comment should not be included. It should be 
included in the parent node that forms the statement.

What is the overall strategy to trailing comments and expressions
Comment 1 Olivier Thomann CLA 2002-03-06 11:30:20 EST
Are you talking about the trailing or the leading comment? I am confused 
between the title of the message and your notes above. Right now we didn't 
define yet how to handle trailing and leading comment.
It might be a good idea to do it now.
Comment 2 Dirk Baeumer CLA 2002-03-06 11:43:45 EST
Sorry my fault. I am talking about the trailing comment
Comment 3 Olivier Thomann CLA 2002-03-06 13:01:52 EST
So what is the general behavior that we want for the trailing comment? Never included? This PR 
won't be fixed until I exactly know what to do about trailing comments.
Comment 4 Jim des Rivieres CLA 2002-03-06 13:53:34 EST
In general, both leading and trailing comments should always be omitted.
The source range for a node should extend from the first character of the
first non-comment, non-whitespace token through the last character of the
last non-comment, non-whitespace token corresponding to that construct.
This range would allow the client to do consistent highlighting and 
character range replacements.

The only exceptions should be:
- Javadoc comments for class, interface, field, method, and constructor
declarations. These should be included in the source range for the major
declaration; the source range for the declaration should begin with the
first character of the opening "/**".

- (debatable) one or more comments immediately preceding a statement

Comment 5 Olivier Thomann CLA 2002-03-06 14:16:44 EST
This can be expensive. Removing trailing and leading comment in an expression means that for all 
expression I have scan again its source in order to set the proper positions.
Comment 6 Olivier Thomann CLA 2002-03-06 17:12:53 EST
I found the problem only for message sends and allocation expression.
Fixed and released in 
HEAD.