Community
Participate
Working Groups
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" ...
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.
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
(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 :-)
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
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.