Community
Participate
Working Groups
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.
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