Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 105956

Summary: [quick assist] Assign to field quick assist does nothing?
Product: [Eclipse Project] JDT Reporter: John Arthorne <john.arthorne>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard: stalebug

Description John Arthorne CLA 2005-08-03 14:47:49 EDT
Build: 3.1 final

Start with this code:

public class B {
	public void foo() {
		if (bar() == 1)
			System.out.println("hello");
	}
	public int bar() {
		return 1;
	}
}

Highlight the reference to "bar()" inside foo().  
Hit Ctrl+2. 
One of the suggestions that appears is "Assign to local variable" with mnemonic
of "L"
Hit letter L.
The popup closes, but nothing happens.

I'm not sure why it won't let me assign the result of bar() to a local variable.
If it's not applicable for that selection, then it shouldn't appear as a proposal.
Comment 1 Dirk Baeumer CLA 2005-08-03 17:19:01 EDT
Martin, can you please comment. Interesting is the fact that Quick Assist itself
doesn't contain Assign to local varaible. It only has extract to local.
Comment 2 Martin Aeschlimann CLA 2005-08-04 04:37:47 EDT
You are talking about the keybinding hint list (in the right lower corner). This
is a platform UI service, and we have no possibility to disable the shortcuts
that  don't apply. But we should at least show a dialog after you chose a
shortcut that is not applicable for the current cursor position.

Assign to local only works for expression statements (its full name is 'assign
statement to new local variable'). What you want is 'extract to local', which
can not be assigned to a shortcut and, as I realize now should be merged to the
first one. I'll do this for 3.2.
Comment 3 John Arthorne CLA 2005-08-04 10:16:49 EDT
That makes sense now - I didn't realize the popup was just the platform UI key
assist dialog.  I was also confusing extract to local (refactoring) and assign
to local (quick assist). I realize now that extract to local is slightly
different because it will also extract other references to that expression. 
Sometimes the line between quick assist and refactoring is very subtle...
Comment 4 Eclipse Genie CLA 2020-04-07 01:04:23 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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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.