| Summary: | [content assist] override method proposal in anonymous class inserts bad stub | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Markus Keller <markus.kell.r> | ||||
| Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> | ||||
| Status: | VERIFIED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | daniel_megert, jarthana, Olivier_Thomann, remy.suen | ||||
| Version: | 3.7 | ||||||
| Target Milestone: | 3.7 M4 | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
This looks like a bug in JDT Core's NodeFinder: in the first case it returns the ExpressionStatement but in the second/correct one, it correctly returns the AnonymousClassDeclaration node. Also, if I remove "hash", do code assist and then select 'hashCode', it also works fine. The problem comes from the positions (start/length) of the assignment node are wrong. They don't include the anonymous type declaration. This is easily visible using the ASTView and double-clicking on the assignment node. Only "field= new Object()" is selected. This is related to the syntax error recovery. Positions are fine if the code doesn't contain syntax errors. Investigating. Created attachment 183147 [details]
Proposed fix + regression test
Released for 3.7M4. Verified for 3.7M4 using build I20101206-1800 |
HEAD Have this example: public class Try { Object field; void foo() { field= new Object() { hash }; } void bar() { Object var= new Object() { hash }; } } Content assist after the first "hash" inserts: public int hashCode() {}; Expected: Same as proposal at second "hash" (formatted, calls super method). See also bug 317497, bug 246343 for similar problems.