Bug 76620 - Selection bug (Open Declaration)
Summary: Selection bug (Open Declaration)
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: Other Linux
: P3 normal (vote)
Target Milestone: 3.1 M3   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-19 20:02 EDT by Carsten Pfeiffer CLA
Modified: 2004-11-04 06:32 EST (History)
0 users

See Also:


Attachments
Patch fixing the bug (860 bytes, patch)
2004-10-19 20:02 EDT, Carsten Pfeiffer CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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