@@ -124,41 +124,17 @@ public TextBuffer toJava(int indent) {
124124        }
125125      }
126126
127-       TextBuffer  body  = KExprProcessor .jmpWrapper (stat , indent  + 2 , true );
128- 
129127      if  (anyNonDefault ) {
130128        buf .append (" -> " );
131-         if  (body .countLines () > 1 ) {
132-           buf .append ("{" )
133-             .appendLineSeparator ()
134-             .append (body )
135-             .appendIndent (indent  + 1 )
136-             .append ("}" )
137-             .appendLineSeparator ();
138-         } else  {
139-           int  indentSize  = ((String ) DecompilerContext .getProperty (IFernflowerPreferences .INDENT_STRING )).length ();
140-           body .setStart (indentSize  * (indent  + 2 ));
141-           buf .append (body );
142-         }
129+         writeCase (indent  + 1 , buf , stat );
143130      }
131+     }
144132
145-       if  (edges .contains (getDefaultEdge ())) {
146-         buf .appendIndent (indent  + 1 )
147-           .append ("else -> " );
148- 
149-         if  (body .countLines () > 1 ) {
150-           buf .append ("{" )
151-             .appendLineSeparator ()
152-             .append (body )
153-             .appendIndent (indent  + 1 )
154-             .append ("}" )
155-             .appendLineSeparator ();
156-         } else  {
157-           int  indentSize  = ((String ) DecompilerContext .getProperty (IFernflowerPreferences .INDENT_STRING )).length ();
158-           body .setStart (indentSize  * (indent  + 2 ));
159-           buf .append (body );
160-         }
161-       }
133+     if  (getDefaultEdge () != null ) {
134+       buf .appendIndent (indent  + 1 )
135+         .append ("else -> " );
136+ 
137+       writeCase (indent  + 1 , buf , getDefaultEdge ().getDestination ());
162138    }
163139
164140    buf .appendIndent (indent )
@@ -179,4 +155,22 @@ public TextBuffer toJava(int indent) {
179155
180156    return  buf ;
181157  }
158+ 
159+   private  void  writeCase (int  indent , TextBuffer  buf , Statement  stat ) {
160+     TextBuffer  body  = KExprProcessor .jmpWrapper (stat , indent  + 1 , true );
161+     if  (body .countLines () > 1 ) {
162+       buf .append ("{" )
163+         .appendLineSeparator ()
164+         .append (body )
165+         .appendIndent (indent )
166+         .append ("}" )
167+         .appendLineSeparator ();
168+     } else  if  (!body .containsOnlyWhitespaces ()) {
169+       int  indentSize  = ((String ) DecompilerContext .getProperty (IFernflowerPreferences .INDENT_STRING )).length ();
170+       body .setStart (indentSize  * (indent  + 1 ));
171+       buf .append (body );
172+     } else  {
173+       buf .append ("{}" ).appendLineSeparator ();
174+     }
175+   }
182176}
0 commit comments