Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 361539 - [Xtend] use extension (i.e. setter) methods for assignments
Summary: [Xtend] use extension (i.e. setter) methods for assignments
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.1.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: SR2   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-20 09:23 EDT by Sven Efftinge CLA
Modified: 2017-09-19 18:09 EDT (History)
2 users (show)

See Also:
sven.efftinge: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Efftinge CLA 2011-10-20 09:23:29 EDT
given the following extension function:

def void setFoo(MyObj it, String prefix) {
   ...
}

I'd like to call it using assignment syntax:

val MyObj x = ...

x.foo = "Hello World"
Comment 1 Knut Wannheden CLA 2011-10-20 10:25:55 EDT
Would it make sense to also allow:

val MyObj x = ...
x.foos += "Hello World"

for something like:

def List<String> getFoos(MyObj it) {
   ...
}

or the JavaBeans addFoo() style?
Comment 2 Sven Efftinge CLA 2011-10-20 10:28:29 EDT
Yes, but that should work already.
Comment 3 Sebastian Zarnekow CLA 2011-10-22 10:29:09 EDT
(In reply to comment #1)
> or the JavaBeans addFoo() style?

JavaBeans only use #add and #remove prefixes for listener registration. That's why we don't have any plans to support the #add prefix for sugared method invocation.
Comment 4 Sebastian Zarnekow CLA 2011-10-22 13:44:50 EDT
(In reply to comment #1)
> val MyObj x = ...
> x.foos += "Hello World"
> 
> for something like:
> 
> def List<String> getFoos(MyObj it) {
>    ...
> }


I added a test case for that example and for the variant that uses even more implicit variables:

..
val MyObj it = ..
foos += "Hello World"
..

def List<String> getFoos(MyObj something) {
..
}
Comment 5 Sebastian Zarnekow CLA 2011-10-24 04:28:56 EDT
Pushed to master.
Comment 6 Karsten Thoms CLA 2017-09-19 17:58:16 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 7 Karsten Thoms CLA 2017-09-19 18:09:02 EDT
Closing all bugs that were set to RESOLVED before Neon.0