Community
Participate
Working Groups
I love the feature that you can do: if (objectClassExpression instanceof Identifier) { objectClassExpression.get[CTRL-SPACE] and that it becomes: ((Identifier)objectClassExpression).getName() problem is that it doesnt work for the most used construct i use when using the instanceof expression: if (objectClassExpression instanceof Identifier) { name = objectClassExpression.get[CTRL-SPACE] then it will not give me the option getName() and doesnt auto cast it. It would be nice if anywhere in that if where you access the variable of the instanceof check you will have the code completion if it was already that Class.
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.