Skip to content

Incorrect indentation level in parameter list of nested record class #9163

@nmatt

Description

@nmatt

Apache NetBeans version

Apache NetBeans 28

What happened

Pressing Enter after a parameter in the parameter list of a nested record class indents the next line incorrectly, as if the record class was one nesting level higher than it actuall is.

Language / Project Type / NetBeans Component

Java, Editor

How to reproduce

Example:

class Example
{
    class Nested
    {
        private record ExampleRecord(
            ProcessHandle processHandle, ThreadGroup threadGroup)
        {
            // ...
        }
    }
}

Pressing Enter after the comma results in:

class Example
{
    class Nested
    {
        private record ExampleRecord(
            ProcessHandle processHandle,
        ThreadGroup threadGroup)
        {
            // ...
        }
    }
}

Whereas the expected result would be:

class Example
{
    class Nested
    {
        record ExampleRecord(
            ProcessHandle processHandle,
            ThreadGroup threadGroup)
        {
            // ...
        }
    }
}

The Nested class is just to illustrate that the resulting indentation level is exactly 1 level too high. The incorrect behavior also happens with one nesting level less.

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows

JDK

JDK 21

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

The generated indentation is correct when the record class is a top-level class. It's only for nested record classes that the indentation level is wrong.

Are you willing to submit a pull request?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    Java[ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)kind:bugBug report or fixneeds:triageRequires attention from one of the committers

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions