Bug 36214 - TODOs reported twice when located at the end of the method declaration
Summary: TODOs reported twice when located at the end of the method declaration
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 minor (vote)
Target Milestone: 3.0 M2   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 37168 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-04-08 10:18 EDT by Olivier Thomann CLA
Modified: 2003-07-16 04:14 EDT (History)
2 users (show)

See Also:


Attachments
Patch the HEAD contents (2.93 KB, patch)
2003-04-08 15:23 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2003-04-08 10:18:19 EDT
Using 2.1:

1) Save the following code using the default settings:

public class Test {

	void foo() {
	} // TODO fix me
}

2) You get two entries in the task list for this TODO item.

We should get only one entry.
Comment 1 Philipe Mulet CLA 2003-04-08 12:36:24 EDT
Is it because of parsing method bodies in separate pass ?
I thought we had some security to prevent recording TODOs in non diet mode.
Comment 2 Olivier Thomann CLA 2003-04-08 12:46:41 EDT
I will investigate.
Comment 3 Olivier Thomann CLA 2003-04-08 14:14:53 EDT
The TODO is processed twice. Once in diet mode and the other one during the
parsing of method bodies.
In diet mode, the jump over method bodies puts the scanner before the comment
that contains the TODO. Therefore it is reported twice. We might want to jump
above the comment that ends a method body. Then we would record only once each TODO.
Comment 4 Olivier Thomann CLA 2003-04-08 15:22:00 EDT
The problem is that the diet mode sets the end of a method declaration to be at
the end of the comment following the closing '}' if it is on the same line. So
in diet mode the comment is parsed once and then during the parsing of the
method bodies it is parsed one more time because the parsing ends at the end of
the comment.
On solution could be to stop the parsing of method bodies after the closing '}'.
Then the following comment would be parsed only once. We would have no more
overlapping in diet and parse method bodies modes.
I changed the value of bodyEnd to be endStatementPosition instead of
endPosition. I made few other changes to use bodyEnd position instead of
declarationSourceEnd and it works fine.
I will attach a patch.
Comment 5 Olivier Thomann CLA 2003-04-08 15:23:25 EDT
Created attachment 4501 [details]
Patch the HEAD contents
Comment 6 Philipe Mulet CLA 2003-04-09 06:51:25 EDT
Why not simply ignore TODOs in non-diet mode ? We only need to collect them 
once, and the jump over method bodies is still tokenizing, thus finding TODOs ?

Comment 7 Olivier Thomann CLA 2003-04-09 09:28:00 EDT
Yes, that could be another solution. I like it better.
Comment 8 Olivier Thomann CLA 2003-05-02 10:58:23 EDT
*** Bug 37168 has been marked as a duplicate of this bug. ***
Comment 9 David Audel CLA 2003-07-01 06:36:59 EDT
Fixed.
Comment 10 David Audel CLA 2003-07-16 04:14:41 EDT
Verified.