This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit 415133ece891d8da1f5e5ec879b6d8fdaa35c00b
Author: Josh Tynjala <joshtynj...@apache.org>
AuthorDate: Thu Sep 14 11:53:53 2023 -0700

    formatter: more tests
---
 .../royale/formatter/TestClassDeclaration.java     | 189 +++++++++++-
 .../apache/royale/formatter/TestConfigConst.java   |  43 +++
 .../royale/formatter/TestDoWhileStatement.java     | 206 ++++++++++++-
 .../royale/formatter/TestElseIfStatement.java      | 299 +++++++++++++++++-
 .../apache/royale/formatter/TestElseStatement.java | 288 +++++++++++++++++-
 .../royale/formatter/TestForEachStatement.java     | 189 +++++++++++-
 .../royale/formatter/TestForInStatement.java       | 188 +++++++++++-
 .../apache/royale/formatter/TestForStatement.java  | 189 +++++++++++-
 .../royale/formatter/TestFunctionDeclaration.java  | 189 +++++++++++-
 .../apache/royale/formatter/TestIfStatement.java   | 191 +++++++++++-
 .../royale/formatter/TestInterfaceDeclaration.java | 189 +++++++++++-
 .../royale/formatter/TestMethodDeclaration.java    | 234 +++++++++++++-
 .../royale/formatter/TestPackageDeclaration.java   | 188 +++++++++++-
 .../royale/formatter/TestSwitchStatement.java      | 159 +++++++++-
 .../royale/formatter/TestTryCatchStatement.java    | 336 ++++++++++++++++++++-
 .../royale/formatter/TestWhileStatement.java       | 190 +++++++++++-
 16 files changed, 3189 insertions(+), 78 deletions(-)

diff --git 
a/formatter/src/test/java/org/apache/royale/formatter/TestClassDeclaration.java 
b/formatter/src/test/java/org/apache/royale/formatter/TestClassDeclaration.java
index a2416a5b5..3bd3788ea 100644
--- 
a/formatter/src/test/java/org/apache/royale/formatter/TestClassDeclaration.java
+++ 
b/formatter/src/test/java/org/apache/royale/formatter/TestClassDeclaration.java
@@ -24,7 +24,7 @@ import org.junit.Test;
 
 public class TestClassDeclaration extends BaseFormatterTests {
        @Test
-       public void testPlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -47,7 +47,31 @@ public class TestClassDeclaration extends BaseFormatterTests 
{
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "class MyClass\n" + 
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "class MyClass\n" +
+                               "{\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -70,7 +94,29 @@ public class TestClassDeclaration extends BaseFormatterTests 
{
        }
 
        @Test
-       public void testPlaceOpenBraceOnNewLineWithStatement() {
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "class MyClass {\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "class MyClass {\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testPlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -95,7 +141,33 @@ public class TestClassDeclaration extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithStatement() {
+       public void testPlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "class MyClass\n" +
+                       "{\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "class MyClass\n" +
+                               "{\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -120,7 +192,31 @@ public class TestClassDeclaration extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testCollapseEmptyBlock() {
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "class MyClass {\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "class MyClass {\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -140,6 +236,89 @@ public class TestClassDeclaration extends 
BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testCollapseEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "class MyClass\n" + 
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "class MyClass {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock3() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "class MyClass\n" + 
+                       "{}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "class MyClass {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock4() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "class MyClass {}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "class MyClass {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock5() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "class MyClass{}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "class MyClass {}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testExtends() {
                FormatterSettings settings = new FormatterSettings();
diff --git 
a/formatter/src/test/java/org/apache/royale/formatter/TestConfigConst.java 
b/formatter/src/test/java/org/apache/royale/formatter/TestConfigConst.java
index c115b44a6..4ac002193 100644
--- a/formatter/src/test/java/org/apache/royale/formatter/TestConfigConst.java
+++ b/formatter/src/test/java/org/apache/royale/formatter/TestConfigConst.java
@@ -212,6 +212,28 @@ public class TestConfigConst extends BaseFormatterTests {
 
        @Test
        public void testCollapseEmptyBlock3() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "COMPILE::JS\n" +
+                       "{}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "COMPILE::JS {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock4() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -231,6 +253,27 @@ public class TestConfigConst extends BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testCollapseEmptyBlock5() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "COMPILE::JS{}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "COMPILE::JS {}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testPlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
diff --git 
a/formatter/src/test/java/org/apache/royale/formatter/TestDoWhileStatement.java 
b/formatter/src/test/java/org/apache/royale/formatter/TestDoWhileStatement.java
index 3cd26e564..10888a9e6 100644
--- 
a/formatter/src/test/java/org/apache/royale/formatter/TestDoWhileStatement.java
+++ 
b/formatter/src/test/java/org/apache/royale/formatter/TestDoWhileStatement.java
@@ -25,7 +25,7 @@ import org.junit.Test;
 
 public class TestDoWhileStatement extends BaseFormatterTests {
        @Test
-       public void testPlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -48,8 +48,35 @@ public class TestDoWhileStatement extends BaseFormatterTests 
{
                                // @formatter:on
                                result);
        }
+
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "do\n" +
+                       "{\n" +
+                       "}\n" +
+                       "while (true);",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "do\n" +
+                               "{\n" +
+                               "}\n" +
+                               "while (true);",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -73,6 +100,30 @@ public class TestDoWhileStatement extends 
BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "do {\n" +
+                       "}\n" +
+                       "while (true);",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "do {\n" +
+                               "}\n" +
+                               "while (true);",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testInsertSpaceAfterControlFlowKeyword() {
                FormatterSettings settings = new FormatterSettings();
@@ -130,7 +181,7 @@ public class TestDoWhileStatement extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testPlaceOpenBraceOnNewLineWithStatement() {
+       public void testPlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -157,7 +208,35 @@ public class TestDoWhileStatement extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithStatement() {
+       public void testPlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "do\n" +
+                       "{\n" +
+                       "\tstatement;\n" +
+                       "}\n" +
+                       "while (true);",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "do\n" +
+                               "{\n" +
+                               "\tstatement;\n" +
+                               "}\n" +
+                               "while (true);",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -183,6 +262,32 @@ public class TestDoWhileStatement extends 
BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "do {\n" +
+                       "\tstatement;\n" +
+                       "}\n" +
+                       "while (true);",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "do {\n" +
+                               "\tstatement;\n" +
+                               "}\n" +
+                               "while (true);",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testBodyWithoutParentheses() {
                FormatterSettings settings = new FormatterSettings();
@@ -381,7 +486,7 @@ public class TestDoWhileStatement extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testCollapseEmptyBlock() {
+       public void testCollapseEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -402,4 +507,95 @@ public class TestDoWhileStatement extends 
BaseFormatterTests {
                                // @formatter:on
                                result);
        }
+
+       @Test
+       public void testCollapseEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "do\n" +
+                       "{\n" +
+                       "}\n" +
+                       "while (condition1);",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "do {}\n" +
+                               "while (condition1);",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock3() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "do\n" +
+                       "{}\n" +
+                       "while (condition1);",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "do {}\n" +
+                               "while (condition1);",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock4() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "do {}\n" +
+                       "while (condition1);",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "do {}\n" +
+                               "while (condition1);",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock5() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "do{}\n" +
+                       "while (condition1);",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "do {}\n" +
+                               "while (condition1);",
+                               // @formatter:on
+                               result);
+       }
 }
diff --git 
a/formatter/src/test/java/org/apache/royale/formatter/TestElseIfStatement.java 
b/formatter/src/test/java/org/apache/royale/formatter/TestElseIfStatement.java
index c253f488b..4781f2281 100644
--- 
a/formatter/src/test/java/org/apache/royale/formatter/TestElseIfStatement.java
+++ 
b/formatter/src/test/java/org/apache/royale/formatter/TestElseIfStatement.java
@@ -25,7 +25,7 @@ import org.junit.Test;
 
 public class TestElseIfStatement extends BaseFormatterTests {
        @Test
-       public void testPlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -55,7 +55,39 @@ public class TestElseIfStatement extends BaseFormatterTests {
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition1)\n" +
+                       "{\n" +
+                       "\tstatement;\n" +
+                       "}\n" +
+                       "else if (condition2)\n" + 
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition1)\n" +
+                               "{\n" +
+                               "\tstatement;\n" +
+                               "}\n" +
+                               "else if (condition2)\n" +
+                               "{\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -85,7 +117,35 @@ public class TestElseIfStatement extends BaseFormatterTests 
{
        }
 
        @Test
-       public void testPlaceOpenBraceOnNewLineWithEmptyIfAndElseIfBlocks() {
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition1) {\n" +
+                       "\tstatement;\n" +
+                       "}\n" +
+                       "else if (condition2) {\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition1) {\n" +
+                               "\tstatement;\n" +
+                               "}\n" +
+                               "else if (condition2) {\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testPlaceOpenBraceOnNewLineWithEmptyIfAndElseIfBlocks1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -113,7 +173,37 @@ public class TestElseIfStatement extends 
BaseFormatterTests {
        }
 
        @Test
-       public void 
testDisablePlaceOpenBraceOnNewLineWithEmptyIfAndElseIfBlocks() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyIfAndElseIfBlocks2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition1)\n" +
+                       "{\n" +
+                       "}\n" +
+                       "else if (condition2)\n" + 
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition1)\n" +
+                               "{\n" +
+                               "}\n" +
+                               "else if (condition2)\n" +
+                               "{\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void 
testDisablePlaceOpenBraceOnNewLineWithEmptyIfAndElseIfBlocks1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -140,6 +230,32 @@ public class TestElseIfStatement extends 
BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void 
testDisablePlaceOpenBraceOnNewLineWithEmptyIfAndElseIfBlocks2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition1) {\n" +
+                       "}\n" +
+                       "else if (condition2) {\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition1) {\n" +
+                               "}\n" +
+                               "else if (condition2) {\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testInsertSpaceAfterControlFlowKeyword() {
                FormatterSettings settings = new FormatterSettings();
@@ -209,7 +325,7 @@ public class TestElseIfStatement extends BaseFormatterTests 
{
        }
 
        @Test
-       public void testPlaceOpenBraceOnNewLineWithStatement() {
+       public void testPlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -241,7 +357,41 @@ public class TestElseIfStatement extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithStatement() {
+       public void testPlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition1)\n" +
+                       "{\n" +
+                       "\tstatement;\n" +
+                       "}\n" +
+                       "else if (condition2)\n" + 
+                       "{\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition1)\n" +
+                               "{\n" +
+                               "\tstatement;\n" +
+                               "}\n" +
+                               "else if (condition2)\n" +
+                               "{\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -272,6 +422,36 @@ public class TestElseIfStatement extends 
BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition1) {\n" +
+                       "\tstatement;\n" +
+                       "}\n" +
+                       "else if (condition2) {\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition1) {\n" +
+                               "\tstatement;\n" +
+                               "}\n" +
+                               "else if (condition2) {\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testBodyWithoutParentheses() {
                FormatterSettings settings = new FormatterSettings();
@@ -517,7 +697,7 @@ public class TestElseIfStatement extends BaseFormatterTests 
{
        }
 
        @Test
-       public void testCollapseEmptyBlock() {
+       public void testCollapseEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -542,4 +722,109 @@ public class TestElseIfStatement extends 
BaseFormatterTests {
                                // @formatter:on
                                result);
        }
+
+       @Test
+       public void testCollapseEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition1)\n" + 
+                       "{\n" +
+                       "}\n" +
+                       "else if (condition2)\n" + 
+                       "{\n" +
+                       "}\n" +
+                       "else\n" +
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition1) {}\n" +
+                               "else if (condition2) {}\n" +
+                               "else {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock3() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition1)\n" + 
+                       "{}\n" +
+                       "else if (condition2)\n" + 
+                       "{}\n" +
+                       "else\n" +
+                       "{}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition1) {}\n" +
+                               "else if (condition2) {}\n" +
+                               "else {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock4() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition1) {}\n" +
+                       "else if (condition2) {}\n" +
+                       "else {}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition1) {}\n" +
+                               "else if (condition2) {}\n" +
+                               "else {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock5() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition1){}\n" +
+                       "else if (condition2){}\n" +
+                       "else{}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition1) {}\n" +
+                               "else if (condition2) {}\n" +
+                               "else {}",
+                               // @formatter:on
+                               result);
+       }
 }
diff --git 
a/formatter/src/test/java/org/apache/royale/formatter/TestElseStatement.java 
b/formatter/src/test/java/org/apache/royale/formatter/TestElseStatement.java
index 4301c0c93..0e6f8445c 100644
--- a/formatter/src/test/java/org/apache/royale/formatter/TestElseStatement.java
+++ b/formatter/src/test/java/org/apache/royale/formatter/TestElseStatement.java
@@ -25,7 +25,7 @@ import org.junit.Test;
 
 public class TestElseStatement extends BaseFormatterTests {
        @Test
-       public void testPlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -55,7 +55,39 @@ public class TestElseStatement extends BaseFormatterTests {
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition)\n" +
+                       "{\n" +
+                       "\tstatement;\n" +
+                       "}\n" +
+                       "else\n" +
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition)\n" +
+                               "{\n" +
+                               "\tstatement;\n" +
+                               "}\n" +
+                               "else\n" +
+                               "{\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -85,7 +117,35 @@ public class TestElseStatement extends BaseFormatterTests {
        }
 
        @Test
-       public void testPlaceOpenBraceOnNewLineWithEmptyIfAndElseBlocks() {
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition) {\n" +
+                       "\tstatement;\n" +
+                       "}\n" +
+                       "else {\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition) {\n" +
+                               "\tstatement;\n" +
+                               "}\n" +
+                               "else {\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testPlaceOpenBraceOnNewLineWithEmptyIfAndElseBlocks1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -113,7 +173,37 @@ public class TestElseStatement extends BaseFormatterTests {
        }
 
        @Test
-       public void 
testDisablePlaceOpenBraceOnNewLineWithEmptyIfAndElseBlocks() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyIfAndElseBlocks2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition)\n" +
+                       "{\n" +
+                       "}\n" +
+                       "else\n" +
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition)\n" +
+                               "{\n" +
+                               "}\n" +
+                               "else\n" +
+                               "{\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void 
testDisablePlaceOpenBraceOnNewLineWithEmptyIfAndElseBlocks1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -141,7 +231,33 @@ public class TestElseStatement extends BaseFormatterTests {
        }
 
        @Test
-       public void testPlaceOpenBraceOnNewLineWithStatement() {
+       public void 
testDisablePlaceOpenBraceOnNewLineWithEmptyIfAndElseBlocks2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition) {\n" +
+                       "}\n" +
+                       "else {\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition) {\n" +
+                               "}\n" +
+                               "else {\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testPlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -173,7 +289,41 @@ public class TestElseStatement extends BaseFormatterTests {
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithStatement() {
+       public void testPlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition)\n" +
+                       "{\n" +
+                       "\tstatement;\n" +
+                       "}\n" +
+                       "else\n" +
+                       "{\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition)\n" +
+                               "{\n" +
+                               "\tstatement;\n" +
+                               "}\n" +
+                               "else\n" +
+                               "{\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -204,6 +354,36 @@ public class TestElseStatement extends BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition) {\n" +
+                       "\tstatement;\n" +
+                       "}\n" +
+                       "else {\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition) {\n" +
+                               "\tstatement;\n" +
+                               "}\n" +
+                               "else {\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testBodyWithoutParentheses() {
                FormatterSettings settings = new FormatterSettings();
@@ -557,7 +737,7 @@ public class TestElseStatement extends BaseFormatterTests {
        }
 
        @Test
-       public void testCollapseEmptyBlock() {
+       public void testCollapseEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -579,4 +759,98 @@ public class TestElseStatement extends BaseFormatterTests {
                                // @formatter:on
                                result);
        }
+
+       @Test
+       public void testCollapseEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition1)\n" +
+                       "{\n" +
+                       "}\n" +
+                       "else\n" + 
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition1) {}\n" +
+                               "else {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock3() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition1)\n" +
+                       "{}\n" +
+                       "else\n" + 
+                       "{}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition1) {}\n" +
+                               "else {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock4() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition1) {}\n" +
+                       "else {}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition1) {}\n" +
+                               "else {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock5() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition1){}\n" +
+                       "else{}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition1) {}\n" +
+                               "else {}",
+                               // @formatter:on
+                               result);
+       }
 }
diff --git 
a/formatter/src/test/java/org/apache/royale/formatter/TestForEachStatement.java 
b/formatter/src/test/java/org/apache/royale/formatter/TestForEachStatement.java
index 8af7c7ef7..d437247dd 100644
--- 
a/formatter/src/test/java/org/apache/royale/formatter/TestForEachStatement.java
+++ 
b/formatter/src/test/java/org/apache/royale/formatter/TestForEachStatement.java
@@ -25,7 +25,7 @@ import org.junit.Test;
 
 public class TestForEachStatement extends BaseFormatterTests {
        @Test
-       public void testPlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -48,7 +48,31 @@ public class TestForEachStatement extends BaseFormatterTests 
{
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for each (var item:Object in array)\n" +
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for each (var item:Object in array)\n" +
+                               "{\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -70,6 +94,28 @@ public class TestForEachStatement extends BaseFormatterTests 
{
                                result);
        }
 
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for each (var item:Object in array) {\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for each (var item:Object in array) {\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testInsertSpaceAfterControlFlowKeyword() {
                FormatterSettings settings = new FormatterSettings();
@@ -123,7 +169,7 @@ public class TestForEachStatement extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testPlaceOpenBraceOnNewLineWithStatement() {
+       public void testPlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -148,7 +194,33 @@ public class TestForEachStatement extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithStatement() {
+       public void testPlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for each (var item:Object in array)\n" + 
+                       "{\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for each (var item:Object in array)\n" +
+                               "{\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -172,6 +244,30 @@ public class TestForEachStatement extends 
BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for each (var item:Object in array) {\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for each (var item:Object in array) {\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testBodyWithoutParentheses() {
                FormatterSettings settings = new FormatterSettings();
@@ -330,7 +426,7 @@ public class TestForEachStatement extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testCollapseEmptyBlock() {
+       public void testCollapseEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -349,4 +445,87 @@ public class TestForEachStatement extends 
BaseFormatterTests {
                                // @formatter:on
                                result);
        }
+
+       @Test
+       public void testCollapseEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for each (var item:Object in array)\n" + 
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for each (var item:Object in array) {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock3() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for each (var item:Object in array)\n" + 
+                       "{}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for each (var item:Object in array) {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock4() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for each (var item:Object in array) {}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for each (var item:Object in array) {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock5() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for each (var item:Object in array){}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for each (var item:Object in array) {}",
+                               // @formatter:on
+                               result);
+       }
 }
diff --git 
a/formatter/src/test/java/org/apache/royale/formatter/TestForInStatement.java 
b/formatter/src/test/java/org/apache/royale/formatter/TestForInStatement.java
index 140d5e96d..52cc3e23f 100644
--- 
a/formatter/src/test/java/org/apache/royale/formatter/TestForInStatement.java
+++ 
b/formatter/src/test/java/org/apache/royale/formatter/TestForInStatement.java
@@ -25,7 +25,7 @@ import org.junit.Test;
 
 public class TestForInStatement extends BaseFormatterTests {
        @Test
-       public void testPlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -47,9 +47,32 @@ public class TestForInStatement extends BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for (var key:String in object)\n" +
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for (var key:String in object)\n" +
+                               "{\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -71,6 +94,28 @@ public class TestForInStatement extends BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for (var key:String in object) {\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for (var key:String in object) {\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testInsertSpaceAfterControlFlowKeyword() {
                FormatterSettings settings = new FormatterSettings();
@@ -124,7 +169,7 @@ public class TestForInStatement extends BaseFormatterTests {
        }
 
        @Test
-       public void testPlaceOpenBraceOnNewLineWithStatement() {
+       public void testPlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -149,7 +194,33 @@ public class TestForInStatement extends BaseFormatterTests 
{
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithStatement() {
+       public void testPlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for (var key:String in object)\n" +
+                       "{\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for (var key:String in object)\n" +
+                               "{\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -173,6 +244,30 @@ public class TestForInStatement extends BaseFormatterTests 
{
                                result);
        }
 
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for (var key:String in object) {\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for (var key:String in object) {\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testBodyWithoutParentheses() {
                FormatterSettings settings = new FormatterSettings();
@@ -331,7 +426,7 @@ public class TestForInStatement extends BaseFormatterTests {
        }
 
        @Test
-       public void testCollapseEmptyBlock() {
+       public void testCollapseEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -350,4 +445,87 @@ public class TestForInStatement extends BaseFormatterTests 
{
                                // @formatter:on
                                result);
        }
+
+       @Test
+       public void testCollapseEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for (var key:String in object)\n" +
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for (var key:String in object) {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock3() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for (var key:String in object)\n" +
+                       "{}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for (var key:String in object) {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock4() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for (var key:String in object) {}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for (var key:String in object) {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock5() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for (var key:String in object){}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for (var key:String in object) {}",
+                               // @formatter:on
+                               result);
+       }
 }
diff --git 
a/formatter/src/test/java/org/apache/royale/formatter/TestForStatement.java 
b/formatter/src/test/java/org/apache/royale/formatter/TestForStatement.java
index 3ef75c3f4..1f3104707 100644
--- a/formatter/src/test/java/org/apache/royale/formatter/TestForStatement.java
+++ b/formatter/src/test/java/org/apache/royale/formatter/TestForStatement.java
@@ -25,7 +25,7 @@ import org.junit.Test;
 
 public class TestForStatement extends BaseFormatterTests {
        @Test
-       public void testPlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -48,7 +48,31 @@ public class TestForStatement extends BaseFormatterTests {
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for (var i:int = 0; i < 3; i++)\n" +
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for (var i:int = 0; i < 3; i++)\n" +
+                               "{\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -70,6 +94,28 @@ public class TestForStatement extends BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for (var i:int = 0; i < 3; i++) {\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for (var i:int = 0; i < 3; i++) {\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testInsertSpaceAfterControlFlowKeyword() {
                FormatterSettings settings = new FormatterSettings();
@@ -123,7 +169,7 @@ public class TestForStatement extends BaseFormatterTests {
        }
 
        @Test
-       public void testPlaceOpenBraceOnNewLineWithStatement() {
+       public void testPlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -148,7 +194,33 @@ public class TestForStatement extends BaseFormatterTests {
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLine() {
+       public void testPlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for (var i:int = 0; i < 3; i++)\n" +
+                       "{\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for (var i:int = 0; i < 3; i++)\n" +
+                               "{\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -172,6 +244,30 @@ public class TestForStatement extends BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for (var i:int = 0; i < 3; i++) {\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for (var i:int = 0; i < 3; i++) {\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testBodyWithoutParentheses() {
                FormatterSettings settings = new FormatterSettings();
@@ -361,7 +457,7 @@ public class TestForStatement extends BaseFormatterTests {
        }
 
        @Test
-       public void testCollapseEmptyBlock() {
+       public void testCollapseEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -380,4 +476,87 @@ public class TestForStatement extends BaseFormatterTests {
                                // @formatter:on
                                result);
        }
+
+       @Test
+       public void testCollapseEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for (var i:int = 0; i < 3; i++)\n" +
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for (var i:int = 0; i < 3; i++) {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock3() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for (var i:int = 0; i < 3; i++)\n" +
+                       "{}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for (var i:int = 0; i < 3; i++) {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock4() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for (var i:int = 0; i < 3; i++) {}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for (var i:int = 0; i < 3; i++) {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock5() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "for (var i:int = 0; i < 3; i++){}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "for (var i:int = 0; i < 3; i++) {}",
+                               // @formatter:on
+                               result);
+       }
 }
diff --git 
a/formatter/src/test/java/org/apache/royale/formatter/TestFunctionDeclaration.java
 
b/formatter/src/test/java/org/apache/royale/formatter/TestFunctionDeclaration.java
index 33d8e9b49..7c60fd237 100644
--- 
a/formatter/src/test/java/org/apache/royale/formatter/TestFunctionDeclaration.java
+++ 
b/formatter/src/test/java/org/apache/royale/formatter/TestFunctionDeclaration.java
@@ -26,7 +26,7 @@ import org.junit.Test;
 // for member functions of classes, see TestMethodDeclaration
 public class TestFunctionDeclaration extends BaseFormatterTests {
        @Test
-       public void testPlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -49,7 +49,31 @@ public class TestFunctionDeclaration extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "function myFunction()\n" + 
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "function myFunction()\n" +
+                               "{\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -72,7 +96,29 @@ public class TestFunctionDeclaration extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testPlaceOpenBraceOnNewLineWithStatement() {
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "function myFunction() {\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "function myFunction() {\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testPlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -97,7 +143,33 @@ public class TestFunctionDeclaration extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithStatement() {
+       public void testPlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "function myFunction()\n" +
+                       "{\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "function myFunction()\n" +
+                               "{\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -121,6 +193,30 @@ public class TestFunctionDeclaration extends 
BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "function myFunction() {\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "function myFunction() {\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testReturnType() {
                FormatterSettings settings = new FormatterSettings();
@@ -334,7 +430,7 @@ public class TestFunctionDeclaration extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testCollapseEmptyBlock() {
+       public void testCollapseEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -354,6 +450,89 @@ public class TestFunctionDeclaration extends 
BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testCollapseEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "function myFunction()\n" +
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "function myFunction() {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock3() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "function myFunction()\n" +
+                       "{}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "function myFunction() {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock4() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "function myFunction() {}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "function myFunction() {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock5() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "function myFunction(){}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "function myFunction() {}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testNested() {
                FormatterSettings settings = new FormatterSettings();
diff --git 
a/formatter/src/test/java/org/apache/royale/formatter/TestIfStatement.java 
b/formatter/src/test/java/org/apache/royale/formatter/TestIfStatement.java
index 0363ec5da..e1c957385 100644
--- a/formatter/src/test/java/org/apache/royale/formatter/TestIfStatement.java
+++ b/formatter/src/test/java/org/apache/royale/formatter/TestIfStatement.java
@@ -25,7 +25,7 @@ import org.junit.Test;
 
 public class TestIfStatement extends BaseFormatterTests {
        @Test
-       public void testPlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -48,7 +48,31 @@ public class TestIfStatement extends BaseFormatterTests {
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (true)\n" +
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (true)\n" +
+                               "{\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -70,6 +94,28 @@ public class TestIfStatement extends BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (true) {\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (true) {\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testInsertSpaceAfterControlFlowKeyword() {
                FormatterSettings settings = new FormatterSettings();
@@ -123,7 +169,7 @@ public class TestIfStatement extends BaseFormatterTests {
        }
 
        @Test
-       public void testPlaceOpenBraceOnNewLineWithStatement() {
+       public void testPlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -147,8 +193,35 @@ public class TestIfStatement extends BaseFormatterTests {
                                result);
        }
 
+
+       @Test
+       public void testPlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (true)\n" +
+                       "{\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (true)\n" +
+                               "{\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithStatement() {
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -172,6 +245,31 @@ public class TestIfStatement extends BaseFormatterTests {
                                result);
        }
 
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (true) {\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (true) {\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testBodyWithoutParentheses() {
                FormatterSettings settings = new FormatterSettings();
@@ -438,7 +536,7 @@ public class TestIfStatement extends BaseFormatterTests {
        }
 
        @Test
-       public void testCollapseEmptyBlock() {
+       public void testCollapseEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -458,6 +556,89 @@ public class TestIfStatement extends BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testCollapseEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition1)\n" +
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition1) {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock3() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition1)\n" +
+                       "{}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition1) {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock4() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition1) {}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition1) {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock5() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "if (condition1){}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "if (condition1) {}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testConditionsOnMultipleLines() {
                FormatterSettings settings = new FormatterSettings();
diff --git 
a/formatter/src/test/java/org/apache/royale/formatter/TestInterfaceDeclaration.java
 
b/formatter/src/test/java/org/apache/royale/formatter/TestInterfaceDeclaration.java
index 0a0e3f38f..82f9738d8 100644
--- 
a/formatter/src/test/java/org/apache/royale/formatter/TestInterfaceDeclaration.java
+++ 
b/formatter/src/test/java/org/apache/royale/formatter/TestInterfaceDeclaration.java
@@ -25,7 +25,7 @@ import org.junit.Test;
 
 public class TestInterfaceDeclaration extends BaseFormatterTests {
        @Test
-       public void testPlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -48,7 +48,31 @@ public class TestInterfaceDeclaration extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "interface MyInterface\n" +
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "interface MyInterface\n" +
+                               "{\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -71,7 +95,29 @@ public class TestInterfaceDeclaration extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testPlaceOpenBraceOnNewLineWithStatement() {
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "interface MyInterface {\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "interface MyInterface {\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testPlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -96,7 +142,33 @@ public class TestInterfaceDeclaration extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithStatement() {
+       public void testPlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "interface MyInterface\n" + 
+                       "{\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "interface MyInterface\n" +
+                               "{\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -120,6 +192,30 @@ public class TestInterfaceDeclaration extends 
BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "interface MyInterface {\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "interface MyInterface {\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testOneMethod() {
                FormatterSettings settings = new FormatterSettings();
@@ -175,7 +271,7 @@ public class TestInterfaceDeclaration extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testCollapseEmptyBlock() {
+       public void testCollapseEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -195,6 +291,89 @@ public class TestInterfaceDeclaration extends 
BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testCollapseEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "interface MyInterface\n" +
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "interface MyInterface {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock3() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "interface MyInterface\n" +
+                       "{}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "interface MyInterface {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock4() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "interface MyInterface {}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "interface MyInterface {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock5() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "interface MyInterface{}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "interface MyInterface {}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testExtends() {
                FormatterSettings settings = new FormatterSettings();
diff --git 
a/formatter/src/test/java/org/apache/royale/formatter/TestMethodDeclaration.java
 
b/formatter/src/test/java/org/apache/royale/formatter/TestMethodDeclaration.java
index 062fef9c9..3c7f1a84d 100644
--- 
a/formatter/src/test/java/org/apache/royale/formatter/TestMethodDeclaration.java
+++ 
b/formatter/src/test/java/org/apache/royale/formatter/TestMethodDeclaration.java
@@ -25,7 +25,7 @@ import org.junit.Test;
 
 public class TestMethodDeclaration extends BaseFormatterTests {
        @Test
-       public void testPlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -53,9 +53,38 @@ public class TestMethodDeclaration extends 
BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "class ClassWithMethod\n" +
+                       "{\n" +
+                       "\tfunction myFunction()\n" +
+                       "\t{\n" +
+                       "\t}\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "class ClassWithMethod\n" +
+                               "{\n" +
+                               "\tfunction myFunction()\n" +
+                               "\t{\n" +
+                               "\t}\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -83,7 +112,34 @@ public class TestMethodDeclaration extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testPlaceOpenBraceOnNewLineWithStatement() {
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "class ClassWithMethod\n" +
+                       "{\n" +
+                       "\tfunction myFunction() {\n" +
+                       "\t}\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "class ClassWithMethod {\n" +
+                               "\tfunction myFunction() {\n" +
+                               "\t}\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testPlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -114,7 +170,39 @@ public class TestMethodDeclaration extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithStatement() {
+       public void testPlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "class ClassWithMethod\n" +
+                       "{\n" +
+                       "\tfunction myFunction()\n" +
+                       "\t{\n" +
+                       "\t\tstatement;\n" +
+                       "\t}\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "class ClassWithMethod\n" +
+                               "{\n" +
+                               "\tfunction myFunction()\n" +
+                               "\t{\n" +
+                               "\t\tstatement;\n" +
+                               "\t}\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -144,7 +232,36 @@ public class TestMethodDeclaration extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testCollapseEmptyBlock() {
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "class ClassWithMethod\n" +
+                       "{\n" +
+                       "\tfunction myFunction() {\n" +
+                       "\t\tstatement;\n" +
+                       "\t}\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "class ClassWithMethod {\n" +
+                               "\tfunction myFunction() {\n" +
+                               "\t\tstatement;\n" +
+                               "\t}\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -169,4 +286,111 @@ public class TestMethodDeclaration extends 
BaseFormatterTests {
                                // @formatter:on
                                result);
        }
+
+       @Test
+       public void testCollapseEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "class ClassWithMethod\n" +
+                       "{\n" +
+                       "\tfunction myFunction()\n" +
+                       "\t{\n" +
+                       "\t}\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "class ClassWithMethod {\n" +
+                               "\tfunction myFunction() {}\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock3() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "class ClassWithMethod\n" +
+                       "{\n" +
+                       "\tfunction myFunction()\n" +
+                       "\t{}\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "class ClassWithMethod {\n" +
+                               "\tfunction myFunction() {}\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock4() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "class ClassWithMethod\n" +
+                       "{\n" +
+                       "\tfunction myFunction() {}\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "class ClassWithMethod {\n" +
+                               "\tfunction myFunction() {}\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock5() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "class ClassWithMethod\n" +
+                       "{\n" +
+                       "\tfunction myFunction(){}\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "class ClassWithMethod {\n" +
+                               "\tfunction myFunction() {}\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
 }
\ No newline at end of file
diff --git 
a/formatter/src/test/java/org/apache/royale/formatter/TestPackageDeclaration.java
 
b/formatter/src/test/java/org/apache/royale/formatter/TestPackageDeclaration.java
index 8fa4d53c3..70ba172b0 100644
--- 
a/formatter/src/test/java/org/apache/royale/formatter/TestPackageDeclaration.java
+++ 
b/formatter/src/test/java/org/apache/royale/formatter/TestPackageDeclaration.java
@@ -25,7 +25,7 @@ import org.junit.Test;
 
 public class TestPackageDeclaration extends BaseFormatterTests {
        @Test
-       public void testPlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -47,9 +47,32 @@ public class TestPackageDeclaration extends 
BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "package\n" + 
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "package\n" +
+                               "{\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -72,7 +95,29 @@ public class TestPackageDeclaration extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testPlaceOpenBraceOnNewLineWithStatement() {
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "package {\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "package {\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testPlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -97,7 +142,33 @@ public class TestPackageDeclaration extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithStatement() {
+       public void testPlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "package\n" +
+                       "{\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "package\n" +
+                               "{\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -121,6 +192,30 @@ public class TestPackageDeclaration extends 
BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "package {\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "package {\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testWithName() {
                FormatterSettings settings = new FormatterSettings();
@@ -147,7 +242,7 @@ public class TestPackageDeclaration extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testCollapseEmptyBlock() {
+       public void testCollapseEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -166,4 +261,87 @@ public class TestPackageDeclaration extends 
BaseFormatterTests {
                                // @formatter:on
                                result);
        }
+
+       @Test
+       public void testCollapseEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "package com.example\n" +
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "package com.example {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock3() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "package com.example\n" +
+                       "{}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "package com.example {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock4() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "package com.example {}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "package com.example {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock5() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "package com.example{}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "package com.example {}",
+                               // @formatter:on
+                               result);
+       }
 }
diff --git 
a/formatter/src/test/java/org/apache/royale/formatter/TestSwitchStatement.java 
b/formatter/src/test/java/org/apache/royale/formatter/TestSwitchStatement.java
index dc034a9e3..1db40e90f 100644
--- 
a/formatter/src/test/java/org/apache/royale/formatter/TestSwitchStatement.java
+++ 
b/formatter/src/test/java/org/apache/royale/formatter/TestSwitchStatement.java
@@ -25,7 +25,7 @@ import org.junit.Test;
 
 public class TestSwitchStatement extends BaseFormatterTests {
        @Test
-       public void testPlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -48,7 +48,31 @@ public class TestSwitchStatement extends BaseFormatterTests {
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "switch (condition)\n" +
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "switch (condition)\n" +
+                               "{\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -70,6 +94,28 @@ public class TestSwitchStatement extends BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                               "switch (condition) {\n" +
+                               "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "switch (condition) {\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testWithCaseClauseAndStatement() {
                FormatterSettings settings = new FormatterSettings();
@@ -971,4 +1017,113 @@ public class TestSwitchStatement extends 
BaseFormatterTests {
                                // @formatter:on
                                result);
        }
+
+       @Test
+       public void testCollapseEmptyBlock1() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "switch (condition) {\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "switch (condition) {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "switch (condition)\n" +
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "switch (condition) {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock3() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "switch (condition)\n" +
+                       "{}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "switch (condition) {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock4() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "switch (condition) {}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "switch (condition) {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock5() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "switch (condition){}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "switch (condition) {}",
+                               // @formatter:on
+                               result);
+       }
 }
diff --git 
a/formatter/src/test/java/org/apache/royale/formatter/TestTryCatchStatement.java
 
b/formatter/src/test/java/org/apache/royale/formatter/TestTryCatchStatement.java
index 9c906dbbd..1c7d7d5c1 100644
--- 
a/formatter/src/test/java/org/apache/royale/formatter/TestTryCatchStatement.java
+++ 
b/formatter/src/test/java/org/apache/royale/formatter/TestTryCatchStatement.java
@@ -25,7 +25,7 @@ import org.junit.Test;
 
 public class TestTryCatchStatement extends BaseFormatterTests {
        @Test
-       public void testPlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -53,7 +53,37 @@ public class TestTryCatchStatement extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "try\n" +
+                       "{\n" +
+                       "}\n" +
+                       "catch (e:Object)\n" +
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "try\n" +
+                               "{\n" +
+                               "}\n" +
+                               "catch (e:Object)\n" +
+                               "{\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -80,6 +110,32 @@ public class TestTryCatchStatement extends 
BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "try {\n" +
+                       "}\n" +
+                       "catch (e:Object) {\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "try {\n" +
+                               "}\n" +
+                               "catch (e:Object) {\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testInsertSpaceAfterControlFlowKeyword() {
                FormatterSettings settings = new FormatterSettings();
@@ -150,7 +206,7 @@ public class TestTryCatchStatement extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testPlaceOpenBraceOnNewLineWithStatement() {
+       public void testPlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -182,7 +238,41 @@ public class TestTryCatchStatement extends 
BaseFormatterTests {
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithStatement() {
+       public void testPlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "try\n" +
+                       "{\n" +
+                       "\tstatement;\n" +
+                       "}\n" +
+                       "catch (e:Object)\n" + 
+                       "{\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "try\n" +
+                               "{\n" + 
+                               "\tstatement;\n" +
+                               "}\n" +
+                               "catch (e:Object)\n" +
+                               "{\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -213,6 +303,36 @@ public class TestTryCatchStatement extends 
BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "try {\n" + 
+                       "\tstatement;\n" +
+                       "}\n" +
+                       "catch (e:Object) {\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "try {\n" +
+                               "\tstatement;\n" +
+                               "}\n" +
+                               "catch (e:Object) {\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testWithCommentBetweenTryStatementAndBody() {
                FormatterSettings settings = new FormatterSettings();
@@ -244,8 +364,9 @@ public class TestTryCatchStatement extends 
BaseFormatterTests {
                                // @formatter:on
                                result);
        }
+
        @Test
-       public void testPlaceOpenBraceOnNewLineWithEmptyBlockWithFinally() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlockWithFinally1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -276,9 +397,45 @@ public class TestTryCatchStatement extends 
BaseFormatterTests {
                                // @formatter:on
                                result);
        }
+       
+       @Test
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlockWithFinally2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "try\n" +
+                       "{\n" +
+                       "}\n" +
+                       "catch (e:Object)\n" + 
+                       "{\n" +
+                       "}\n" +
+                       "finally\n" + 
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "try\n" +
+                               "{\n" +
+                               "}\n" +
+                               "catch (e:Object)\n" +
+                               "{\n" +
+                               "}\n" +
+                               "finally\n" +
+                               "{\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
 
        @Test
-       public void 
testDisablePlaceOpenBraceOnNewLineWithEmptyBlockWithFinally() {
+       public void 
testDisablePlaceOpenBraceOnNewLineWithEmptyBlockWithFinally1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -309,4 +466,171 @@ public class TestTryCatchStatement extends 
BaseFormatterTests {
                                // @formatter:on
                                result);
        }
+
+       @Test
+       public void 
testDisablePlaceOpenBraceOnNewLineWithEmptyBlockWithFinally2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "try {\n" +
+                       "}\n" +
+                       "catch (e:Object) {\n" +
+                       "}\n" +
+                       "finally {\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "try {\n" +
+                               "}\n" +
+                               "catch (e:Object) {\n" +
+                               "}\n" +
+                               "finally {\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock1() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "try {\n" +
+                       "}\n" +
+                       "catch (e:Object) {\n" +
+                       "}\n" +
+                       "finally {\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "try {}\n" +
+                               "catch (e:Object) {}\n" +
+                               "finally {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "try\n" +
+                       "{\n" +
+                       "}\n" +
+                       "catch (e:Object)\n" +
+                       "{\n" +
+                       "}\n" +
+                       "finally\n" +
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "try {}\n" +
+                               "catch (e:Object) {}\n" +
+                               "finally {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock3() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "try\n" +
+                       "{}\n" +
+                       "catch (e:Object)\n" +
+                       "{}\n" +
+                       "finally\n" +
+                       "{}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "try {}\n" +
+                               "catch (e:Object) {}\n" +
+                               "finally {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock4() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "try {}\n" +
+                       "catch (e:Object) {}\n" +
+                       "finally {}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "try {}\n" +
+                               "catch (e:Object) {}\n" +
+                               "finally {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock5() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "try{}\n" +
+                       "catch (e:Object){}\n" +
+                       "finally{}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "try {}\n" +
+                               "catch (e:Object) {}\n" +
+                               "finally {}",
+                               // @formatter:on
+                               result);
+       }
 }
diff --git 
a/formatter/src/test/java/org/apache/royale/formatter/TestWhileStatement.java 
b/formatter/src/test/java/org/apache/royale/formatter/TestWhileStatement.java
index 1909ca998..1f43f5f5f 100644
--- 
a/formatter/src/test/java/org/apache/royale/formatter/TestWhileStatement.java
+++ 
b/formatter/src/test/java/org/apache/royale/formatter/TestWhileStatement.java
@@ -25,7 +25,7 @@ import org.junit.Test;
 
 public class TestWhileStatement extends BaseFormatterTests {
        @Test
-       public void testPlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -33,7 +33,7 @@ public class TestWhileStatement extends BaseFormatterTests {
                ASTokenFormatter formatter = new ASTokenFormatter(settings);
                String result = formatter.format("file.as",
                // @formatter:off
-                       "while (true)\n\n{\n" +
+                       "while (true) {\n" +
                        "}",
                        // @formatter:on
                        problems
@@ -47,9 +47,32 @@ public class TestWhileStatement extends BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testPlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "while (true)\n" +
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "while (true)\n" +
+                               "{\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock() {
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -71,6 +94,28 @@ public class TestWhileStatement extends BaseFormatterTests {
                                result);
        }
 
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "while (true) {\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "while (true) {\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testInsertSpaceAfterControlFlowKeyword() {
                FormatterSettings settings = new FormatterSettings();
@@ -124,7 +169,7 @@ public class TestWhileStatement extends BaseFormatterTests {
        }
 
        @Test
-       public void testPlaceOpenBraceOnNewLineWithStatement() {
+       public void testPlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = true;
@@ -149,7 +194,33 @@ public class TestWhileStatement extends BaseFormatterTests 
{
        }
 
        @Test
-       public void testDisablePlaceOpenBraceOnNewLineWithStatement() {
+       public void testPlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = true;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "while (true)\n" +
+                       "{\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "while (true)\n" +
+                               "{\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -173,6 +244,30 @@ public class TestWhileStatement extends BaseFormatterTests 
{
                                result);
        }
 
+       @Test
+       public void testDisablePlaceOpenBraceOnNewLineWithStatement2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.insertSpaces = false;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "while (true) {\n" +
+                       "\tstatement;\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "while (true) {\n" +
+                               "\tstatement;\n" +
+                               "}",
+                               // @formatter:on
+                               result);
+       }
+
        @Test
        public void testBodyWithoutParentheses() {
                FormatterSettings settings = new FormatterSettings();
@@ -331,7 +426,7 @@ public class TestWhileStatement extends BaseFormatterTests {
        }
 
        @Test
-       public void testCollapseEmptyBlock() {
+       public void testCollapseEmptyBlock1() {
                FormatterSettings settings = new FormatterSettings();
                settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
                settings.placeOpenBraceOnNewLine = false;
@@ -350,4 +445,87 @@ public class TestWhileStatement extends BaseFormatterTests 
{
                                // @formatter:on
                                result);
        }
+
+       @Test
+       public void testCollapseEmptyBlock2() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "while (condition1)\n" +
+                       "{\n" +
+                       "}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "while (condition1) {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock3() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "while (condition1)\n" +
+                       "{}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "while (condition1) {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock4() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "while (condition1) {}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "while (condition1) {}",
+                               // @formatter:on
+                               result);
+       }
+
+       @Test
+       public void testCollapseEmptyBlock5() {
+               FormatterSettings settings = new FormatterSettings();
+               settings.insertSpaceAfterKeywordsInControlFlowStatements = true;
+               settings.placeOpenBraceOnNewLine = false;
+               settings.collapseEmptyBlocks = true;
+               ASTokenFormatter formatter = new ASTokenFormatter(settings);
+               String result = formatter.format("file.as",
+               // @formatter:off
+                       "while (condition1){}",
+                       // @formatter:on
+                       problems
+               );
+               assertEquals(
+               // @formatter:off
+                               "while (condition1) {}",
+                               // @formatter:on
+                               result);
+       }
 }

Reply via email to