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

Bug 340440

Summary: [inline] inline string variable should avoid string concatenation
Product: [Eclipse Project] JDT Reporter: Nikolay Metchev <nikolaymetchev>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: enhancement    
Priority: P3 CC: markus.kell.r
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Nikolay Metchev CLA 2011-03-18 11:27:38 EDT
When you inline the variable a in the snippet below it would be very good if eclipse remove the concatenation code:
==== INPUT =====
    String a = "1";
    String n = "b" + a + "c" + a;
================

==== OUTPUT ====
    String n = "b1c1";
================
Comment 1 Markus Keller CLA 2011-03-24 07:18:13 EDT
I agree that this could be handy sometimes, but we want to keep refactorings targeted to perform a single action (avoid guessing and being too smart, since it's not always clear that the user really wants/needs the additional smartness).

A decent compiler already concatenates the resulting "b" + "1" + "c" + "1" into one string, so this is also not a performance concern.

What we could do though, is add a quick fix that concatenates sequences of string literals into one, i.e. "b" + "1" + "c" + "1" => "b1c1", see bug 77632.