Skip to content

Formatter - curly bracket is not moved to same line #1318

@jangalda-nsc

Description

@jangalda-nsc

I try to format groovy code using Eclipse formatter, but in some cases opening curly bracket stays in newline despite having groovy.formatter.braces.start=same configured.

My environment:

  • Groovy Development Tools-4.3.0.RELEASE
  • Eclipse version 2021-09 (4.21.0)
  • Java Formatter settings - default builtin
  • Groovy formatter settings:
groovy.formatter.braces.end=next
groovy.formatter.braces.start=same
groovy.formatter.longListLength=100
groovy.formatter.multiline.indentation=4
groovy.formatter.remove.unnecessary.semicolons=true
org.eclipse.jdt.core.formatter.indent_empty_lines=false
org.eclipse.jdt.core.formatter.tabulation.char=space
org.eclipse.jdt.core.formatter.tabulation.size=4

The same issue occurs when I use spotless gradle plugin and greplise with configuration above

The most basic code to reproduce the issue:

def method1() {
	// Both comment and block with curly brackets are needed
	if (true) {
		println("method1")
	}
}


def method2()
{
	println("method2")
}

In example above, the lonely opening bracket of method2 is not formatted. It works ok if I remove comment or if statement from method1.

I have little experience with Eclipse, so I'm not sure if I did something wrong, or there is a bug in Groovy Eclipse Formatter.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions