Summary: | [code assist] The instanceof and the auto cast feature should also work for an assignment | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Johan Compagner <jcompagner> | ||||||||
Component: | Core | Assignee: | Ayushman Jain <amj87.iitr> | ||||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||||
Severity: | enhancement | ||||||||||
Priority: | P3 | CC: | Olivier_Thomann, srikanth_sankaran | ||||||||
Version: | 3.5 | ||||||||||
Target Milestone: | 3.6 M6 | ||||||||||
Hardware: | PC | ||||||||||
OS: | Windows NT | ||||||||||
Whiteboard: | |||||||||||
Attachments: |
|
Description
Johan Compagner
2009-08-28 05:54:45 EDT
Reassigning to Ayushman since he is looking at it. Created attachment 158833 [details]
Fix + Tests v0.1
Initial patch that mostly works.
Created attachment 159290 [details]
fix + tests v0.2
Here's a fix with minor changes to srikanth's patch above. Added 2 more test cases.
It works fine whenever the code assist is asked immediately after the if(...instanceof..) check. However, it doesnt work if there are any other expressions in between viz:
Object a;
int i = 1;
if(a instance of X){
if(i == 1)
i = a.[CTRL-SPACE]
}
Will open a separate bug report for the above and a few other cases where autocast doesnt work.
> It works fine whenever the code assist is asked immediately after the > if(...instanceof..) check. However, it doesnt work if there are any other > expressions in between viz: > > Object a; > int i = 1; > if(a instance of X){ > if(i == 1) > i = a.[CTRL-SPACE] > } For the record, this limitation is not new with this patch and has always existed. See bug#193909 comment#12. So even in the case cited as the working example in comment#0, if you introduce an inner if, completion fails. Created attachment 159397 [details]
Proposed patch
Same patch as from Ayush with small changes:
(1) Eliminated formatting changes in lines not modified for
this patch.
(2) if (this.expressionPtr > 0
&& this.expressionStack[this.expressionPtr - 1] != null
&& this.expressionStack[this.expressionPtr - 1] instanceof InstanceOfExpression)
is better written as
if (this.expressionPtr > 0
&& this.expressionStack[this.expressionPtr - 1] instanceof InstanceOfExpression)
as null is guaranteed NOT to be an instance of any type.
Released in HEAD for 3.6M6 Verified for 3.6M6 using I20100307-2000. |