| Summary: | [quick assist] 'Introduce new local with cast type' should be available at more locations | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Deepak Azad <deepakazad> | ||||||||
| Component: | UI | Assignee: | Deepak Azad <deepakazad> | ||||||||
| Status: | VERIFIED FIXED | QA Contact: | |||||||||
| Severity: | normal | ||||||||||
| Priority: | P3 | CC: | akiezun, daniel_megert, markus.kell.r, raksha.vasisht | ||||||||
| Version: | 3.7 | Flags: | markus.kell.r:
review+
|
||||||||
| Target Milestone: | 3.7 M4 | ||||||||||
| Hardware: | All | ||||||||||
| OS: | All | ||||||||||
| Whiteboard: | |||||||||||
| Attachments: |
|
||||||||||
Created attachment 183993 [details]
fix + tests
Cool, thanks. Please release. We could even go one step further and also enable it if the caret is before the first statement in the block (bug 104395 comment 2). *** Bug 104395 has been marked as a duplicate of this bug. *** Created attachment 184059 [details] final fix + tests (In reply to comment #2) > We could even go one step further and also enable it if the caret is before the > first statement in the block (bug 104395 comment 2). Done this as well. Fixed in HEAD. The quick assist should also work for a non-block if-statement just as it works when ctrl+1 is invoked on 'instanceof' keyword. It creates the new local var and surrounds it with curly braces. Ex: if(obj instanceof String) | // show quick assist here Created attachment 184770 [details] additional fix + tests (In reply to comment #6) > The quick assist should also work for a non-block if-statement just as it works > when ctrl+1 is invoked on 'instanceof' keyword. It creates the new local var > and surrounds it with curly braces. > > Ex: > if(obj instanceof String) > | // show quick assist here Fair enough. Fixed in this case void bar(Object obj) { if(obj instanceof String) | //invoke quick assist here return; } Note that it will still not work in the following case void bar(Object obj) { if(obj instanceof String) | //invoke quick assist here } This case is a bit tricky as in this case the if statement is not complete and the AST tells that the quick assist is invoked on the method declaration block. (In reply to comment #7) > Created an attachment (id=184770) [details] [diff] > additional fix + tests Fixed in HEAD. Verified in 3.7 M7. |
The quick assist is available only on 'instanceof' keyword, which is a bit irritating. Object obj = s; if(obj instanceof String){ | //I typically want the quick assist on this line } The quick assist can be made available - Inside the if/while blocks, if the block is empty and the condition is an InstanceofExpression - anywhere in the if/while statement's expression Fix will go in AdvancedQuickAssistProcessor#getCastAndAssignIfStatementProposals(..)