Community
Participate
Working Groups
Extract constant / local variable / method refactorings don't work with certain selections that contain whitespace. Example: class Test { { foo( "bla" ) ; } static int foo(String s) { return s.length(); } } If whitespace before and/or after "bla" is selected, all Extract... refactorings still show up and work fine. If whitespace after foo( "bla" ) is selected, then the Extract... refactorings work fine, but if whitespace before foo( "bla" ) is selected, they don't show up. The problem is that SelectionAnalyzer only skips whitespace that belongs to the directly enclosing node (the ExpressionStatement in this case), but the whitespace in front of foo belongs to the enclosing Block.
See also bug 428139: [extract local] Extract local variable should be possible without selection This works for me from all caret positions on the the foo( "bla" ) ; line, but under the condition that no text has been selected. An explicitly selected text range is another thing. Should we respect the user's choice when the text range is invalid for the particular action or try to interpret it as something else? I thought I knew the answer but apparently the answer is something else, because I see a Quick Assist called "Assign statement to a new local variable" which shows up for this snippet even if the line comment is the only thing selected: class Test { { foo("bla") // select this comment and assign me to a variable ; } static int foo(String s) { return s.length(); } }
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.