Index: CodeFormatterVisitor.java
===================================================================
--- CodeFormatterVisitor.java	(.../trunk/eclipseformatter/CodeFormatterVisitor.java)	(revision 37)
+++ CodeFormatterVisitor.java	(.../branches/ef-changed/eclipseformatter/CodeFormatterVisitor.java)	(revision 37)
@@ -1,3 +1,9 @@
+/*
+ * This file has been modified to allow the code
+ * formatter to insert curly braces {}.
+ * See http://kruithof.xs4all.nl//eclipseform/eclipsewithbraces.html
+ * for more info.
+ */
 /*******************************************************************************
  * Copyright (c) 2002, 2005 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
@@ -3178,15 +3184,9 @@
 				formatNecessaryEmptyStatement();
 			} else {
 				this.scribe.printNewLine();
-				this.scribe.indent();
-				action.traverse(this, scope);
-				if (action instanceof Expression) {
-					this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
-					this.scribe.printTrailingComment();
-					this.scribe.printNewLine();
-				}
-				this.scribe.unIndent();
-			}
+                /* Martijn Kruithof {} */
+                formatStatementAsBlock(scope, line, action);
+            }
 		} else {
 			/*
 			 * This is an empty statement
@@ -3489,15 +3489,10 @@
 				 */
 				formatNecessaryEmptyStatement();
 			} else {
-				this.scribe.indent();
-				this.scribe.printNewLine();
-				action.traverse(this, scope);
-				this.scribe.unIndent();
-			}
-			if (action instanceof Expression) {
-				this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
-				this.scribe.printTrailingComment();
-			}
+                this.scribe.printNewLine();
+                /* Martijn Kruithof {} */
+                formatStatementAsBlock(scope, line, action);
+            }
 		} else {
 			/*
 			 * This is an empty statement
@@ -3575,15 +3570,10 @@
 				 */
 				formatNecessaryEmptyStatement();
 			} else {
-				this.scribe.indent();
 				this.scribe.printNewLine();
-				action.traverse(this, scope);
-				this.scribe.unIndent();
-			}
-			if (action instanceof Expression) {
-				this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
-				this.scribe.printTrailingComment();
-			}
+                /* Martijn Kruithof {} */
+                formatStatementAsBlock(scope, line, action);
+            }
 		} else {
 			/*
 			 * This is an empty statement
@@ -3668,16 +3658,11 @@
 			} else {
 				this.scribe.printTrailingComment();
 				this.scribe.printNewLine();
-				this.scribe.indent();
-				thenStatement.traverse(this, scope);
-				if (thenStatement instanceof Expression) {
-					this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
-					this.scribe.printTrailingComment();
-				}
-				if (elseStatement != null) {
+                /* Martijn Kruithof {} */
+                formatStatementAsBlock(scope, line, thenStatement);
+                if (elseStatement != null) {
 					this.scribe.printNewLine();
 				}
-				this.scribe.unIndent();
 			}
 		}
 		
@@ -3708,13 +3693,8 @@
 				}
 			} else {
 				this.scribe.printNewLine();
-				this.scribe.indent();
-				elseStatement.traverse(this, scope);
-				if (elseStatement instanceof Expression) {
-					this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
-					this.scribe.printTrailingComment();
-				}
-				this.scribe.unIndent();
+                /* Martijn Kruithof {} */
+                formatStatementAsBlock(scope, line, elseStatement);
 			}
 		}
 		return false;
@@ -5171,13 +5151,8 @@
 				formatNecessaryEmptyStatement();
 			} else {
 				this.scribe.printNewLine();
-				this.scribe.indent();
-				action.traverse(this, scope);
-				if (action instanceof Expression) {
-					this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
-					this.scribe.printTrailingComment();
-				}
-				this.scribe.unIndent();
+                /* Martijn Kruithof {} */
+                formatStatementAsBlock(scope, line, action);
 			}
 		} else {
 			/*
@@ -5227,4 +5202,23 @@
 		}
 		return false;
 	}
+    
+        /* Martijn Kruithof {} */
+    private void formatStatementAsBlock(BlockScope scope, final int line,
+            final Statement statement) {
+        formatLeftCurlyBrace(line, this.preferences.brace_position_for_block);
+        this.scribe
+                .insertLBrace(this.preferences.insert_space_before_opening_brace_in_block);
+        this.scribe.indent();
+        this.scribe.printNewLine();
+        statement.traverse(this, scope);
+        if (statement instanceof Expression) {
+            this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON,
+                    this.preferences.insert_space_before_semicolon);
+            this.scribe.printTrailingComment();
+        }
+        this.scribe.unIndent();
+        this.scribe.printNewLine();
+        this.scribe.insertRBrace(true);
+    }
 }
