Bug 66463 - [Comments] Extended positions DOM/AST nodes need addtional improvements
Summary: [Comments] Extended positions DOM/AST nodes need addtional improvements
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P5 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on: 54204 66026
Blocks:
  Show dependency tree
 
Reported: 2004-06-10 03:06 EDT by Frederic Fusier CLA
Modified: 2020-02-24 17:55 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Fusier CLA 2004-06-10 03:06:50 EDT
This is next step after bug 66026 fix.

In DefaultCommentMapper, node extended start position algorithm can be optimized
by using same mechanism than for end position (-1 when node starts at same
position of its parent).

We want also refine extended positions computation for nodes which gets their
extended start or end position from their parent.

I will provide some examples to illustrate what we want to refine in this
heuristic and the impact on existing behavior...
Comment 1 Frederic Fusier CLA 2004-06-10 03:10:21 EDT
Post 3.0
Comment 2 Frederic Fusier CLA 2004-06-10 03:14:35 EDT
First example:
/*c1*/ org.eclipse.jdt.core.dom.DefaultCommentMapper /*c2*/ dcm;

In this statement currently /*c1*/ is attached only to full qualified name and
/*c2*/ is attached both to full qualified name and simple name DefaultCommentMapper
There's no reason that attachement was different for leading than for trailing
comments.

We think that it should be the same for both comments. So either /*c1*/ should
also be attached to org, org.eclipse, etc... or /*c2*/ should not be attached to
simple name DefaultCommentMapper
Comment 3 Frederic Fusier CLA 2004-06-10 03:27:45 EDT
Second example:
	int x /*c1*/;
	int y
	/*c2*/
	;

Currently /*c1*/ and /*c2*/ are respectively attached to simple names x and y.

It looks not really natural for child node to be attached to a comment which is
on a different line.

So, we would like heuristic behaves as followed:
	/*c1a*/ int x /*c1b*/;
	/*c2a*/
	int y
	/* c2b*/
	;
/*c1a*/ attached both field declaration x and type int
/*c2b*/ attached to simple name x
/*c2a*/ attached to field declaration y but not to type int (not on same line)
/*c2b*/ not attached to simple name y
Comment 4 Frederic Fusier CLA 2004-06-10 03:31:37 EDT
Third example:
void foo() {
}
/*c1*/
/*c2*/

Currently /*c1*/ and /*c2*/ are both attached to method declaration *and* body.

If this ok for method declaration this is not correct for body which should not
have any comment attached.

A variation of this example is:
void foo() {
} /*c1*/
/*c2*/

Then we should always expect /*c1*/ and /*c2*/ attached to method declaration
and only /*c1*/ attached to the body...
Comment 5 Martin Aeschlimann CLA 2004-06-10 13:53:49 EDT
For the ASTRewrite it is important that a comment node is only assigned to one 
AST node. What would be problematic is if in the case of
/*c1*/ org.eclipse.jdt.core.dom.DefaultCommentMapper /*c2*/ dcm;
'c2' would belong 'org.eclipse.jdt.core.dom.DefaultCommentMapper' and to 'dcm' 
as well: This would result in overlapping edits when e.g. you replace both.

But I think that's not what you meant. In the case of
/*c1*/ org.eclipse.jdt.core.dom.DefaultCommentMapper 
I think a comment should map to the largest element, so here the full 
qualified type.
Comment 6 Frederic Fusier CLA 2007-06-21 07:25:56 EDT
Reopen as LATER is deprecated...
Comment 7 Eclipse Genie CLA 2020-02-24 17:55:01 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.