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

Bug 354946

Summary: [xtend2] quick fix for application of += operator on String objects not supported
Product: [Modeling] TMF Reporter: Matthias Wienand <matthias.wienand>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: enhancement    
Priority: P3 CC: nyssen, sebastian.zarnekow, sven.efftinge
Version: 2.0.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Matthias Wienand CLA 2011-08-17 09:11:51 EDT
Build Identifier: I20110613-1736

The infix operator '+=' is not supported by Xtend. Using it causes Xtend to underline the operator as if it were an error, providing a tooltip that reads: "Couldn't resolve reference to JvmIdentifiableElement '+='".

Example:
[xtend]
var i1 = 1
var i2 = 1
i1 += i2
[/xtend]

Moreover, quick fixes (replacing the '+=' operator with a comparison operator) are not available for String objects.

Reproducible: Always

Steps to Reproduce:
1. Create a new .xtend class
2. Define a method and type the following in the method body:
var i1 = 1
var i2 = 1
i1 += i2
Comment 1 Sven Efftinge CLA 2011-08-17 09:18:21 EDT
The operator '+=' is mapped to functions with the name 'add' (operator overloading). Since int doesn't define such a function (and there is no such extension function defined as well) the operator is not available for int. It wouldn't behave like in C or Java though, because ints are immutable.
Comment 2 Matthias Wienand CLA 2011-08-17 09:31:32 EDT
(In reply to comment #1)
> The operator '+=' is mapped to functions with the name 'add' (operator
> overloading). Since int doesn't define such a function (and there is no such
> extension function defined as well) the operator is not available for int. It
> wouldn't behave like in C or Java though, because ints are immutable.

Okay. I expected it to work like in Java. Now I took a closer look at the documentation and noticed the difference between _operator_add() and _operator_plus() :)

However, there is no quick fix available for Strings, though similar looking operators (<=) exist.
Comment 3 Sebastian Zarnekow CLA 2011-10-17 16:50:48 EDT
Closed as won't fix since similar looking is not really similar if 50% of the characters are different. It would actually involve less keystrokes to fix the operator manually instead of scrolling through a list of proposals like
!=, ==, <=, >=, <, >
where even the alphabetic order is not too meaningful for the user.
Comment 4 Karsten Thoms CLA 2017-09-19 17:01:09 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 5 Karsten Thoms CLA 2017-09-19 17:12:33 EDT
Closing all bugs that were set to RESOLVED before Neon.0