### Eclipse Workspace Patch 1.0
#P org.codehaus.groovy.eclipse.refactoring.test
Index: resources/Formatter/Formatter_Test_GRE_197_spaced_out.txt
===================================================================
--- resources/Formatter/Formatter_Test_GRE_197_spaced_out.txt	(revision 0)
+++ resources/Formatter/Formatter_Test_GRE_197_spaced_out.txt	(revision 0)
@@ -0,0 +1,46 @@
+###prop
+setPreferences=true
+bracesEnd=next
+###src
+class EmailCommand
+{
+	String email
+	String messageContent
+
+	static constraints =
+	{
+		email("email": true, "blank": false)
+		messageContent("blank": false)
+	}
+
+	void fun()
+	{
+		def a = [3]
+		a.each
+				{
+				println it
+
+			}
+
+
+
+	}
+}
+###exp
+class EmailCommand {
+	String email
+	String messageContent
+	
+	static constraints = {
+		email("email": true, "blank": false)
+		messageContent("blank": false)
+	}
+	
+	void fun() {
+		def a = [3]
+		a.each {
+			println it
+		}
+	}
+}
+###end
\ No newline at end of file
Index: resources/Formatter/Formatter_Test_Braces_Start_Next.txt
===================================================================
--- resources/Formatter/Formatter_Test_Braces_Start_Next.txt	(revision 20075)
+++ resources/Formatter/Formatter_Test_Braces_Start_Next.txt	(working copy)
@@ -44,7 +44,9 @@
 				print 3
 		}
 		"hello".each
-				{ print it }
+				{
+					print it
+				}
 	}
 }
 ###end
\ No newline at end of file
Index: resources/Formatter/Formatter_Test_GRE_197.txt
===================================================================
--- resources/Formatter/Formatter_Test_GRE_197.txt	(revision 0)
+++ resources/Formatter/Formatter_Test_GRE_197.txt	(revision 0)
@@ -0,0 +1,40 @@
+###prop
+setPreferences=true
+bracesEnd=next
+###src
+class EmailCommand
+{
+String email
+				String messageContent
+
+static constraints =
+{
+		email("email": true, "blank": false)
+		messageContent("blank": false)
+}
+	
+void fun()
+	{
+def a = [3]
+		a.each
+				{
+							println it
+}}}
+###exp
+class EmailCommand {
+	String email
+	String messageContent
+	
+	static constraints = {
+		email("email": true, "blank": false)
+		messageContent("blank": false)
+	}
+	
+	void fun() {
+		def a = [3]
+		a.each {
+			println it
+		}
+	}
+}
+###end
\ No newline at end of file
Index: resources/Formatter/Formatter_Test_spaced_out.txt
===================================================================
--- resources/Formatter/Formatter_Test_spaced_out.txt	(revision 0)
+++ resources/Formatter/Formatter_Test_spaced_out.txt	(revision 0)
@@ -0,0 +1,21 @@
+###prop
+setPreferences=true
+bracesEnd=next
+###src
+class EmailCommand {
+	def foo () {
+		return 1
+		
+		
+	}
+	
+	
+	
+}
+###exp
+class EmailCommand {
+	def foo () {
+		return 1
+	}
+}
+###end
\ No newline at end of file
Index: resources/Formatter/Formatter_Test_Braces_Start_Same.txt
===================================================================
--- resources/Formatter/Formatter_Test_Braces_Start_Same.txt	(revision 20075)
+++ resources/Formatter/Formatter_Test_Braces_Start_Same.txt	(working copy)
@@ -45,7 +45,9 @@
 			case 3:
 				print 3
 		}
-		"hello".each { print it }
+		"hello".each {
+			print it
+		}
 	}
 }
 ###end
\ No newline at end of file
Index: resources/Formatter/Formatter_Test_Braces_End_Next.txt
===================================================================
--- resources/Formatter/Formatter_Test_Braces_End_Next.txt	(revision 20075)
+++ resources/Formatter/Formatter_Test_Braces_End_Next.txt	(working copy)
@@ -31,7 +31,9 @@
 			case 3:
 				print 3
 		}
-		"hello".each { print it }
+		"hello".each {
+			print it
+		}
 	}
 }
 ###end
\ No newline at end of file
Index: resources/Formatter/Formatter_Test_Braces_End_Same.txt
===================================================================
--- resources/Formatter/Formatter_Test_Braces_End_Same.txt	(revision 20075)
+++ resources/Formatter/Formatter_Test_Braces_End_Same.txt	(working copy)
@@ -34,5 +34,6 @@
 		switch (3) {
 			case 3:
 				print 3 }
-		"hello".each { print it } } }
+		"hello".each {
+			print it } } }
 ###end
\ No newline at end of file
Index: resources/Formatter/Formatter_Test_Closure_Combine.txt
===================================================================
--- resources/Formatter/Formatter_Test_Closure_Combine.txt	(revision 20075)
+++ resources/Formatter/Formatter_Test_Closure_Combine.txt	(working copy)
@@ -13,7 +13,9 @@
 	print param
 }
 ###exp
-"hello".each { print it }
+"hello".each {
+	print it
+}
 5.times { param ->
 	print param
 	print param
#P org.codehaus.groovy.eclipse.refactoring
Index: src/org/codehaus/groovy/eclipse/refactoring/formatter/GroovyBeautifier.java
===================================================================
--- src/org/codehaus/groovy/eclipse/refactoring/formatter/GroovyBeautifier.java	(revision 20079)
+++ src/org/codehaus/groovy/eclipse/refactoring/formatter/GroovyBeautifier.java	(working copy)
@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2007, 2009 Martin Kempf, Reto Kleeb, Michael Klenk
  *
  * IFS Institute for Software, HSR Rapperswil, Switzerland
@@ -18,9 +18,9 @@
  */
 package org.codehaus.groovy.eclipse.refactoring.formatter;
 
-import antlr.Token;
 import java.util.HashSet;
 import java.util.Set;
+
 import org.codehaus.groovy.antlr.parser.GroovyTokenTypes;
 import org.codehaus.groovy.ast.ASTNode;
 import org.codehaus.groovy.ast.expr.ClosureExpression;
@@ -37,12 +37,14 @@
 import org.eclipse.text.edits.ReplaceEdit;
 import org.eclipse.text.edits.TextEdit;
 
+import antlr.Token;
+
 /**
  * @author Mike Klenk mklenk@hsr.ch
  *
  */
 public class GroovyBeautifier {
-	
+
 	public DefaultGroovyFormatter formatter;
 	private final FormatterPreferences preferences;
 	private final Set<Token> ignoreToken;
@@ -57,10 +59,10 @@
 
 	public TextEdit getBeautifiEdits() throws MalformedTreeException, BadLocationException {
 		MultiTextEdit edits = new MultiTextEdit();
-		
-		combineClosures(edits);
+
+        combineClosures(edits);
 		correctBraces(edits);
-	
+
 		return edits;
 	}
 
@@ -85,7 +87,7 @@
 				ignoreToken.add(formatter.getTokens().get(posCLEnd));
 				continue;
 			}
-			
+
 			if (clExp.getCode() instanceof BlockStatement) {
 				BlockStatement codeblock = (BlockStatement) clExp.getCode();
 				int posParamDelim = posClStart;
@@ -94,21 +96,18 @@
 					posParamDelim = formatter.getPosOfNextTokenOfType(posClStart, GroovyTokenTypes.CLOSABLE_BLOCK_OP);
 					replaceNLSWithSpace(edits, posClStart, posParamDelim);
 				}
-				// combine closure with only one statments with less than 5 tokens to one line
-				if(codeblock.getStatements().size() == 1 && (posCLEnd - posClStart) < 10) {
-					replaceNLSWithSpace(edits, posParamDelim, posCLEnd);
-					ignoreToken.add(formatter.getTokens().get(posCLEnd));
-				} else {
-					// check if there is a linebreak after the parameters
-					if(posParamDelim > 0 && formatter.getNextTokenIncludingNLS(posParamDelim).getType() != GroovyTokenTypes.NLS) {
-						addEdit(new InsertEdit(formatter.getOffsetOfTokenEnd(formatter.getTokens().get(posParamDelim)), formatter.getNewLine()),edits);
-					} else { 
-						// If there are no parameters check if the first statement is on the next line
-						if(posParamDelim == 0 && formatter.getNextTokenIncludingNLS(posClStart).getType() != GroovyTokenTypes.NLS) {
-							addEdit(new InsertEdit(formatter.getOffsetOfTokenEnd(formatter.getTokens().get(posClStart)), formatter.getNewLine()),edits);
-						}
-					}
-				}
+                // check if there is a linebreak after the parameters
+                if (posParamDelim > 0 && formatter.getNextTokenIncludingNLS(posParamDelim).getType() != GroovyTokenTypes.NLS) {
+                    addEdit(new InsertEdit(formatter.getOffsetOfTokenEnd(formatter.getTokens().get(posParamDelim)), formatter
+                            .getNewLine()), edits);
+                } else {
+                    // If there are no parameters check if the first statement
+                    // is on the next line
+                    if (posParamDelim == 0 && formatter.getNextTokenIncludingNLS(posClStart).getType() != GroovyTokenTypes.NLS) {
+                        addEdit(new InsertEdit(formatter.getOffsetOfTokenEnd(formatter.getTokens().get(posClStart)), formatter
+                                .getNewLine()), edits);
+                    }
+                }
 			}
 		}
 	}
@@ -126,7 +125,7 @@
 					skipNextNLS = false;
 				} else {
 					int offset = formatter.getOffsetOfToken(token);
-					int lenght = formatter.getOffsetOfToken(formatter.getNextToken(p)) - offset;	
+					int lenght = formatter.getOffsetOfToken(formatter.getNextToken(p)) - offset;
 					addEdit(new ReplaceEdit(offset,lenght," "), container);
 				}
 			}
@@ -144,10 +143,10 @@
 			rCurlyCorrector = new SameLine(this);
 		if(preferences.bracesEnd == FormatterPreferences.NEXT_LINE)
 			rCurlyCorrector = new NextLine(this);
-		
+
 		assert lCurlyCorrector != null;
 		assert rCurlyCorrector != null;
-		
+
 		Token token;
 		boolean skipNextNLS = false;
 		for (int i = 0; i < formatter.getTokens().size(); i++) {
@@ -172,7 +171,7 @@
 			}
 		}
 	}
-	
+
 	private void addEdit(TextEdit edit,TextEdit container) {
 		if(edit != null && edit.getOffset() >= formatter.formatOffset &&
 				edit.getOffset() + edit.getLength() <= formatter.formatOffset + formatter.formatLength) {
Index: src/org/codehaus/groovy/eclipse/refactoring/formatter/lineWrap/NextLine.java
===================================================================
--- src/org/codehaus/groovy/eclipse/refactoring/formatter/lineWrap/NextLine.java	(revision 20079)
+++ src/org/codehaus/groovy/eclipse/refactoring/formatter/lineWrap/NextLine.java	(working copy)
@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2007, 2009 Martin Kempf, Reto Kleeb, Michael Klenk
  *
  * IFS Institute for Software, HSR Rapperswil, Switzerland
@@ -18,7 +18,6 @@
  */
 package org.codehaus.groovy.eclipse.refactoring.formatter.lineWrap;
 
-import org.codehaus.groovy.antlr.parser.GroovyTokenTypes;
 import org.codehaus.groovy.eclipse.refactoring.formatter.GroovyBeautifier;
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.text.edits.ReplaceEdit;
@@ -44,12 +43,10 @@
 	@Override
 	public ReplaceEdit correctLineWrap(int pos, Token token) throws BadLocationException {
 		ReplaceEdit correctEdit = null;
-		if(beautifier.formatter.getPreviousTokenIncludingNLS(pos).getType() != GroovyTokenTypes.NLS) {
-			Token lastNotNLSToken = beautifier.formatter.getPreviousToken(pos);
-			int replaceStart = beautifier.formatter.getOffsetOfTokenEnd(lastNotNLSToken) ;
-			int replaceEnd = beautifier.formatter.getOffsetOfToken(token);
-			correctEdit = new ReplaceEdit(replaceStart,replaceEnd-replaceStart,beautifier.formatter.getNewLine());
-		}
+        Token lastNotNLSToken = beautifier.formatter.getPreviousToken(pos);
+        int replaceStart = beautifier.formatter.getOffsetOfTokenEnd(lastNotNLSToken);
+        int replaceEnd = beautifier.formatter.getOffsetOfToken(token);
+        correctEdit = new ReplaceEdit(replaceStart, replaceEnd - replaceStart, beautifier.formatter.getNewLine());
 		return correctEdit;
 	}
 
