Community
Participate
Working Groups
Hi, there's a bug in HandleFactory's method public IJavaElement createElement( final ASTNode toBeFound, CompilationUnitDeclaration parsedUnit, Openable openable) In its local class Visitor, the push() method enlarges the array 'nodeStack' by creating a bigger one and copying the previous elements to the new one. However, one element is lost, because the last argument to the System.arrayCopy() call is 'this.nodeIndex-1', which is 1 too little. This is because nodeIndex starts with -1, so it is always 1 less than elements in the array. Simple test scenario: create a bunch of nested local classes (to reach the default array size of 10) and try to select an element, e.g. by putting the cursor on 'foo' and hitting F3. Selection will not work. public class Deep { class D1 { class D2 { class D3 { class D4 { class D5 { class D6 { class D7 { class D8 { class D9 { public D9() { String foo = "foo"; foo += "42"; } } } } } } } } } } }
Created attachment 15290 [details] Patch fixing the bug
Your patch is correct. Thanks Fixed and test addes ResolveTest#testDeepLocalVariable()
Verified for 3.1 M3 with build I200411040010 + jdt.core HEAD