Community
Participate
Working Groups
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.
Is it because of parsing method bodies in separate pass ? I thought we had some security to prevent recording TODOs in non diet mode.
I will investigate.
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.
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.
Created attachment 4501 [details] Patch the HEAD contents
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 ?
Yes, that could be another solution. I like it better.
*** Bug 37168 has been marked as a duplicate of this bug. ***
Fixed.
Verified.