Bug 82464

Summary: pick out selected part of String does not work as expected [quick assist]
Product: [Eclipse Project] JDT Reporter: Akmal <as>
Component: UIAssignee: Martin Aeschlimann <martinae>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: Konstantin.Scheglov
Version: 3.1   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Fix for getPickOutStringProposals none

Description Akmal CLA 2005-01-10 07:11:15 EST
when applying the quick assist on the several parts of a String only the last
one is applyied

e.g if I want to have "eclipse "+"is "+"very "+"cool " from "eclipse is very
cool" with the help of the quick assist, I only get the last result and the
previous extraction dissapears.
Comment 1 Martin Aeschlimann CLA 2005-01-10 10:45:46 EST
Can you give steps? I couldn't reproduce this. The only thing I found is that
the quick assist is not offered on the second string literal
Comment 2 Akmal CLA 2005-01-10 11:09:53 EST
input String is "eclipse is very cool"

select >>cool<<         -> "eclipse is very " + "cool" // as expected
select >>very <<        -> "eclipse is " + "very " + "cool" // still..
now select >>is <<      -> "eclipse " + "is " + "very cool" // ??
then select >>eclipse<< -> "eclipse" + " is very cool" //??
Comment 3 Martin Aeschlimann CLA 2005-01-10 11:13:45 EST
Konstantin, if you're interested...
Comment 4 Konstantin Scheglov CLA 2005-01-13 13:23:21 EST
  Interesting problem.

  As I can see in JDT Core source, expression "a" + "b" + "c" is _single_
StringLiteral object! So, when we ask for covering node, we receive full string
value and really generate only up to 3 string parts. I don't think that we can
do anything rational with this.

  In reallity this quick fix can not be applyed at all to strings that consist
of several parts, because we can not map selection in source to position in
escaped string. For example here: "1" + "2{start select}3{end select}" selection
in source is 8 (relative from beginning of StringLiteral), but in espaced string
- only 3, but we can not know this.

  I will add to quick assist check that string consists of single part, see
patch in attachment.
  
  As workaround I suggest you extract pieces of string into separate variables.
In reallity this is why I need this quick assist - I write first rough text,
that should be parametrized, then pick out parts of string and place them in
parameters. You may be also noticed that picked out part string is selected, so
you need just press hot key for "Extract local variable".
  
Comment 5 Konstantin Scheglov CLA 2005-01-13 13:24:56 EST
Created attachment 17141 [details]
Fix for getPickOutStringProposals
Comment 6 Martin Aeschlimann CLA 2005-01-14 04:11:01 EST
This is a bug in the AST. I filed bug 82830.
Didn't release the patch, jdt.core should fix this

*** This bug has been marked as a duplicate of 82830 ***