Flip Setter Call Intention Action in Maia

Two-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.

This entry was posted in New Features and tagged , . Bookmark the permalink.

4 Responses to Flip Setter Call Intention Action in Maia

  1. Jesper Thuun-Petersen says:

    In what build is this supposed to be implemented? I’m using 10322, and I’m not getting this intention.

  2. Stephen Friedrich says:

    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.

  3. Konstantin Bulenkov says:

    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)

  4. Konstantin Bulenkov says:

    Jesper, this intention is available in build 10332.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>