Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 328674

Summary: [assist] local being declared proposed inside its initialization
Product: [Eclipse Project] JDT Reporter: Ayushman Jain <amj87.iitr>
Component: CoreAssignee: Ayushman Jain <amj87.iitr>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: srikanth_sankaran
Version: 3.7Flags: srikanth_sankaran: review+
Target Milestone: 3.7 M4   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
proposed fix v1.0 + regression tests none

Description Ayushman Jain CLA 2010-10-26 02:06:10 EDT
From bug 325481 comment 6

public class Test {
    public static void main() {
        String field1 = "";
        String field2 = String.format(fie|);
        String field3 = "hello";
    String field4 = "";
    }
}

Completing at | proposes field2 which proposal if you accept
you get an immediate compiler error.
Comment 1 Ayushman Jain CLA 2010-10-26 15:26:59 EDT
Created attachment 181766 [details]
proposed fix v1.0 + regression tests

This fix is on the lines of the one done for bug 312603, except that for the latter it was done in InternalExtendedCompletionContext, which affects the proposed parameters when completing a method call inside a local's initialization. When directly completing, this fix should suffice.

This makes use of the fact that a local variables initialization will only be non null when the completion is inside the initialization, else it will be set to null by consumeExitVariableWithInitialization().
Comment 2 Ayushman Jain CLA 2010-10-26 15:27:46 EDT
Srikanth, please review. TIA
Comment 3 Srikanth Sankaran CLA 2010-10-27 04:44:11 EDT
Looks good.
Comment 4 Ayushman Jain CLA 2010-11-05 10:48:40 EDT
Released in HEAD for 3.7M4
Comment 5 Srikanth Sankaran CLA 2010-12-07 00:43:43 EST
Verified for 3.7M4 using build id I20101205-2000