Formatting If Statements

Has anyone found a combination of formatting options that will turn:

        if (2 < 3) {             return;         } else if (2 > 3) {             return;         } else {             return;         }



Into

        if (2 < 3)             return;         else if (2 > 3)             return;         else             return;         



Of course never this:

        if (2 < 3)
             if (2 > 3)
                 return;
             else
                 return;            

 
Which should always be bracketed

        if (2 < 3) {
             if (2 > 3)                  return;              else                  return;
        }    

4 comments
Comment actions Permalink

Hi Jon,

No, IJ formatter doesn't provide an ability to remove curly braces.

Denis

0
Comment actions Permalink

Hi Dennis,

Thanks for the reply.

Let me give you a better view as to what I mean:

12-6-2012 12-23-40.png

12-6-2012 12-23-54.png


So, right now it looks like:

        if (2 < 3) return;         else if (2 > 3) return;         else return;



and I would like:

        if (2 < 3)
           return;         else if (2 > 3)
           return;         else
           return;


Sorry, my original question was misleading I think. I just want to prevent the else clauses getting folded up while still keeping "Control statements one line".

0
Comment actions Permalink

Well, combinations of two settings below make that possible:

  • Wrapping and Braces | Keep when reformatting | Control statements in one line - unchecked;
  • Wrapping and Braces | 'if' statement | Force braces - Do not force;

Regards, Denis

0
Comment actions Permalink

Hi Denis,

I opened a ticket since I think it is not possible at the moment.

http://youtrack.jetbrains.com/issue/IDEA-97107

0

Please sign in to leave a comment.