Bug 82464 - pick out selected part of String does not work as expected [quick assist]
Summary: pick out selected part of String does not work as expected [quick assist]
Status: RESOLVED DUPLICATE of bug 82830
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Martin Aeschlimann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-10 07:11 EST by Akmal CLA
Modified: 2005-01-14 04:11 EST (History)
1 user (show)

See Also:


Attachments
Fix for getPickOutStringProposals (892 bytes, patch)
2005-01-13 13:24 EST, Konstantin Scheglov CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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 ***