Flip Setter Call Intention Action in Maia
June 2nd, 2009 by Konstantin BulenkovTwo-way synchronization between different data models is a common routine task and often developers are stuck with manual copying of data from one model to another for many reasons: model complexity, impossibility to create a simple binding, etc. For example, we have a settings model and an UI to configure it. Traditional approach suggests implementing two methods:
- Initializing UI from settings
- Persisting changes from UI to settings

Next, we need to implement a method (say, saveSettings), similar to initUI where UI changes are persisted to the ProxySetting object — quite boring, isn’t it?
How to do it quicker than just writing from scratch? In Maia we’ll do it twice as easy: copy the body of initUI method to saveSettings, select the just pasted code and press Alt+Enter.
Then, select Flip Setter Call intention action and enjoy.
Tags: Intentions, maia
June 2nd, 2009 at 6:55 am
In what build is this supposed to be implemented? I’m using 10322, and I’m not getting this intention.
June 3rd, 2009 at 3:43 am
Is there a way to invoke the intention on a bunch of setters/getters at once?
Maybe select some statements, then press alt-enter.
Or “Fix all for current method” which may work for the “saveSettings” scenario - but then again maybe not: There’s always a chance of there being some additional accessor calls in the method that are unrelated to the settings per se.
June 3rd, 2009 at 4:29 am
Sure. You can select a huge code block and call “Flip Setter Call”. It will look for method calls like:
object1.setProperty(object2.getOtherProperty());
after that it checks that object1 and object2 have appropriate getter and setter with the same types, and finally swaps method calls
And, of course, it works on single method call (without any selection)
June 3rd, 2009 at 8:38 am
Jesper, this intention is available in build 10332.