Bug 76620

Summary: Selection bug (Open Declaration)
Product: [Eclipse Project] JDT Reporter: Carsten Pfeiffer <carsten.pfeiffer>
Component: CoreAssignee: David Audel <david_audel>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.0   
Target Milestone: 3.1 M3   
Hardware: Other   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Patch fixing the bug none

Description Carsten Pfeiffer CLA 2004-10-19 20:02:07 EDT
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"; 
                            } 
                        } 
                       } 
                      } 
                     } 
                 } 
             } 
         } 
     } 
    } 
}
Comment 1 Carsten Pfeiffer CLA 2004-10-19 20:02:51 EDT
Created attachment 15290 [details]
Patch fixing the bug
Comment 2 David Audel CLA 2004-10-27 07:00:19 EDT
Your patch is correct. Thanks

Fixed and test addes
   ResolveTest#testDeepLocalVariable()
Comment 3 Frederic Fusier CLA 2004-11-04 06:32:43 EST
Verified for 3.1 M3 with build I200411040010 + jdt.core HEAD