If the option Place trailing closure arguments after closing parenthesis is checked and you try to write a constructor call with a closure as the last parameter, Greclipse pushes the opening brace outside the closing round parenthesis:
MyClass c = new MyClass('foo', |)
If you type { at "|", you'll get:
MyClass c = new MyClass('foo', ) {
Apart from the fact that the comma is left behind, this won't produce a valid result because:
MyClass c = new MyClass('foo') {
}
is seen as a creation of an anonymous in-place extension of MyClass rather than a call to MyClass constructor with trailing closure, in fact:
MyClass c = new MyClass('foo') { foo, bar ->
}
is seen as a syntax error ("unexpected token: foo").
For constructor calls, you can't use the syntax that puts the trailing closure parameters outside the round parenthesis, at least in Groovy 2.x (I don't know how it works in Groovy 3, but I think it would be ambiguous if it let do it).
If the option
Place trailing closure arguments after closing parenthesisis checked and you try to write a constructor call with a closure as the last parameter, Greclipse pushes the opening brace outside the closing round parenthesis:If you type
{at "|", you'll get:Apart from the fact that the comma is left behind, this won't produce a valid result because:
is seen as a creation of an anonymous in-place extension of
MyClassrather than a call toMyClassconstructor with trailing closure, in fact:is seen as a syntax error ("unexpected token: foo").
For constructor calls, you can't use the syntax that puts the trailing closure parameters outside the round parenthesis, at least in Groovy 2.x (I don't know how it works in Groovy 3, but I think it would be ambiguous if it let do it).