Community
Participate
Working Groups
Build Identifier: 3.6M6 In the following cases, try invoking content assist after the | 1) public class Test { int field1 = 1; int abc = new int[]{fie| } 2) public class Test { public static final AClass a1 = new AClass( new byte[][] {\n" + {0x00,0x3C},{0x04,0x2C}}); public static final AC| " + } class AClass{ public byte[][] field1; public AClass(byte[][] byteArray) { field1 = byteArray; } } Content Assist doesnt work in both cases. Reproducible: Always Steps to Reproduce: 1.Use any of the two cases above 2.Invoke content assist via CTRL-SPACE. 3.See that expected proposals dont turn up
Created attachment 164755 [details] proposed fix v1.0 + regression tests The problem is that in RecoveredField#updateOnOpeningBrace(), the logic does not consider the case that an initializer might occur inside a field declaration even if the field is not an array type. At present, we close the field declaration when we encounter the initializer and attach the initializer to the parent type instead. So an initializer in a field declaration ends up as an initializer in the parent type. The problem manifest in the AST obtained after diet parse (if it enters recovery), and also when content assist is invoked after the declaration of a field containing an initializer. The patch addresses these issues. The change in RecoveredField#updateOnClosingBrace is necessary to ensure that we dont set the field to have been initialized even if we're still in the declaration (declarationSourceEnd is not set until the field declaration is not exited completely). Some tests in CompletionParserTest2 and DietRecoveryTest had to be remastered.
Btw, I'd mentioned "local variable" in the bug title by mistake. This problem is only in case of field declarations. Srikanth can you please review? Thanx!
(In reply to comment #0) > Build Identifier: 3.6M6 > Content Assist doesnt work in both cases. Actually it does work as expected on HEAD. Ayush, please post the correct test and rework the patch as needed.
> Actually it does work as expected on HEAD. Ayush, please post > the correct test and rework the patch as needed. Sorry i gave the wrong test case. The one to reproduce the problem is : public class Try { public static final AClass a1 = new JustTry( new byte[][] { {0x00,0x3C}, {0x04,0x2C}}) { int justReturn(int a) { return a; } }; public static final AC | } class AClass{ public byte[][] field1; public AClass(byte[][] byteArray) { field1 = byteArray; } } abstract class JustTry extends AClass{ public byte[][] field1; JustTry(byte[][] byteArray){ field1 = byteArray; } abstract int justReturn(int a); } Also for the case 1, we do get the completion, but we dont get the correct completion AST. Changes in CompletionParserTest2 reflect all the places where an initializer bracket inside a non array field initializer would make the parser skip out the completion node from the AST. Eg: public class X { Object o = new X[]{zzz; } would give us public class X { Object o ; { } public X(){} }.
Created attachment 165399 [details] proposed fix v1.0 + updated regression tests Updated the regression test in CompletionTests
Created attachment 165632 [details] proposed fix v2.0 + regression tests the above fix was only for SingleTypeReferences. So, on Srikanth's suggestion, extending it for all non-array type reference cases.
Released in HEAD for 3.6M7
*** Bug 310187 has been marked as a duplicate of this bug. ***
Verified for 3.6M7 using build I20100424-2000