Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 363435 - [quick assist] "Assign statement to local variable" should insert cast if type changed
Summary: [quick assist] "Assign statement to local variable" should insert cast if typ...
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.8   Edit
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2011-11-10 04:16 EST by Lars Vogel CLA
Modified: 2021-04-15 13:07 EDT (History)
5 users (show)

See Also:


Attachments
Example (5.59 KB, image/png)
2011-11-10 04:29 EST, Lars Vogel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2011-11-10 04:16:12 EST
CTRL+2 L allows to assign a statement to a new locale variable.

I use CTRL+2 L a lot, one of the best shortcuts in Eclipse IHMO. 

What would be nice if that I change the type on the left side of the equation and this type does not fit to the right hand-side that a cast is automatically added. Currently I have to select the right hand-side and use Ctrl+1 to add the cast.

I attached a screenshot. If I would change the type on the left side, then I would get an error and have to use Ctrl+1.
Comment 1 Lars Vogel CLA 2011-11-10 04:29:45 EST
Created attachment 206768 [details]
Example
Comment 2 Deepak Azad CLA 2011-11-10 05:20:05 EST
Markus, is it possible to set up linked mode in such a way that a cast is added when the user changes the type on LHS? 


void bar() {
	Object foo = foo(); // change type in LHS while still in linked mode
}
	
Object foo(){
	return null;
}
Comment 3 Markus Keller CLA 2011-11-10 05:59:50 EST
> Markus, is it possible to set up linked mode in such a way that a cast is added
> when the user changes the type on LHS? 

No, AFAIK, this is not supported at the moment. The "linking" of the linked mode is implemented in LinkedPositionGroup#handleEvent(DocumentEvent), and that is currently not open for arbitrary transformations supplied by specific quick fixes.

But I remember we had other situations where this would have been handy (e.g. the "for - iterate over collection" template).
Comment 4 Lars Vogel CLA 2017-01-27 06:09:23 EST
See also Bug 511175 for a quickfix in a similar area.
Comment 5 Eclipse Genie CLA 2021-04-15 13:04:24 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.