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

Bug 198791

Summary: [extract local] selects complete line after applied
Product: [Eclipse Project] JDT Reporter: Hans Meier <eclipseBugs>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: martinae
Version: 3.3   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Hans Meier CLA 2007-08-03 05:51:16 EDT
Build ID:  I20070625-1500

Steps To Reproduce:
1. Example: enter "System.getProperties()"
2. Hit Alt+Shift+L
3. Enter variable name and press return
4. As a result the whole line is selected which does not really makes sense


More information:
After applying "extract local variable", the cursor should be put to the end of the line without selecting the complete line or alternatively (maybe as an option) it should create a new line and place the cursor at the beginning of the line.

Background: When using this refactoring to just speedup coding, you want to proceed with coding after applying the alt+shift+l shortcut.
However currently after applying this shortcut I have to press the end key to move the cursor at the end of the line and then I have to press Enter to proceed. 99% of the time these are the two additional unnecessary key strokes I have to make after alt+shift+l.

I'm thinking of the IntelliJ IDEA way of refactorings: each shortcut (wether it be refactorings or not) was implemented in a way that after applying them you can proceed with coding with as less keystrokes as possible.

The new inplace "extract local variable" (ctrl+2, L) removes the modal dialog, but e.g. does not insert a semicolon at the end of the line which makes it unfortunately taking also the same amount of keystrokes as the variant with the modal dialog.


Regards
Comment 1 Martin Aeschlimann CLA 2007-08-17 10:11:31 EDT
Currently, the refactoring just restores the selection to what was selected before. I also don't see what's the benefit of that.

The last point is a good one too: Assign to local/field should add a semicolon if it is missing. I filed bug 200362 for this.
Comment 2 Martin Aeschlimann CLA 2007-08-17 11:06:44 EDT
Your example is less a 'extract' than an 'assign'. So I just fixed the 'assign to local' quick fix (bug 200362) and I believe that solves your problem.

I'm not sure if we can find a better end selection for 'extract local' except for the example you gave, which I think is not so typical.
Comment 3 Hans Meier CLA 2007-08-20 04:42:58 EDT
You're right, my usecase is more "assign" than "extract" so the missing semicolon will "fix" my problem (though I would still like to see an option of automatically inserting a new line after this quick fix...)

However you are wrong with the selection of the refactoring. As I wrote in the steps to reproduce, I only type "System.getProperties()" before hitting the refactoring shortcut. I don't select what I just typed in. Thus nothing is selected when applying the refactoring.
After the refactoring however the whole line is selected which is not what was selected before.

Anyway thx for fixing the missing semicolon.

Comment 4 Eclipse Genie CLA 2019-09-23 09:44:17 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.