Skip to content

Indent of an "else if" is 1 level short when inside an argument that is a Function declared inline - if the Function argument is not on the first line of the call #2643

@costescuandrei

Description

@costescuandrei

Version:

Eclipse IDE for RCP and RAP Developers (includes Incubating components)
Version: 2025-09 (4.37.0)
Build id: 20250905-1456

You can reproduce this easily by applying the Eclipse formatter, using the attached formatter settings, in this (stupid) class file - I reduced it to this from a much larger, logical one :) :

import java.util.function.Function;

public class DummyDeleteMe
{

	public void callY()
	{
		callX(
			(DummyDeleteMe arg) -> {
				if (arg == null) System.out.println("");
				else if (true)
			{
				System.out.println("");
			}
				return arg;
			});
	}

	private void callX(Function<DummyDeleteMe, DummyDeleteMe> f)
	{
		f.apply(this);
	}

}

There, the "{" after the "else if (true)" line is indented 1 level too little.

If I change the class to remove the newline after "callX(", so have the inline Function argument start on the same line, then it works correctly.
I attached the formatter settings used for that Java/Plugin project.

formatter_settings.xml

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions