Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 328674 - [assist] local being declared proposed inside its initialization
Summary: [assist] local being declared proposed inside its initialization
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.7 M4   Edit
Assignee: Ayushman Jain CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-26 02:06 EDT by Ayushman Jain CLA
Modified: 2010-12-07 00:43 EST (History)
1 user (show)

See Also:
srikanth_sankaran: review+


Attachments
proposed fix v1.0 + regression tests (4.89 KB, patch)
2010-10-26 15:26 EDT, Ayushman Jain CLA
no flags Details | Diff

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