Bug 103797 - [quick assist] Extract String variable from selected text in a literal string
Summary: [quick assist] Extract String variable from selected text in a literal string
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: All All
: P4 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-14 08:46 EDT by Channing Walton CLA
Modified: 2009-01-23 11:36 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Channing Walton CLA 2005-07-14 08:46:58 EDT
Hi,
extracting a variable from a string would be useful (for me at least ;)

e.g. given

.... "a string with some stuff etc" ...

select the phrase 'some stuff' and extract it to a new variable:

String var = "some stuff";
.... "a string with " + var + " etc" ...
Comment 1 Dani Megert CLA 2005-07-18 09:35:11 EDT
You can press 'Return' which breaks the string into parts and then use
refactoring to extract the string into a local variable or constant.

Moving to JDT UI to consider either a new refactoring or quick assist. Don't
think it's needed though.
Comment 2 Markus Keller CLA 2005-07-18 12:39:16 EDT
I agree that extracting to a local variable is a very specific request. Moving
to Martin to consider as a quick assist or to close (I agree with either solution).

The easiest way I know about is this:
- select 'some stuff'
- Ctrl+1, Enter  (select quick assist 'Pick out selected part of String'
- Alt+Shift+L    (Extract Local Variable)
- give a name, Enter
Comment 3 Channing Walton CLA 2005-07-18 16:31:39 EDT
(In reply to comment #1)
> You can press 'Return' which breaks the string into parts and then use
> refactoring to extract the string into a local variable or constant.

Ah, I never realised that :-)
Comment 4 Thorsten van Ellen CLA 2006-05-19 17:09:54 EDT
Funny, this is the second bug/feature, that I am reading the last days and for a long time. And it's the second time, that I read the name of Martin. Seems as if he has nearly the same ideas like me :-)

best regards

Thorsten van Ellen
Comment 5 Martin Aeschlimann CLA 2006-05-22 04:06:15 EDT
Oh, I'm only the assignee of the bug here, credits go to Channing.
Actually, we just collect all Quick Fix / Quick Assist improvement ideas here in my inbox. I wouldn't mind implementing more of these features (including this one), but it is hard to find time for enhancements and new features as other (critical) issues have priority.