This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 186023 - Extra newline inserted before the class closing brace
Summary: Extra newline inserted before the class closing brace
Status: VERIFIED INVALID
Alias: None
Product: javafx
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: PC Mac OS X
: P4 normal (vote)
Assignee: Anton Chechel
URL:
Keywords:
Depends on:
Blocks: 173487
  Show dependency tree
 
Reported: 2010-05-12 15:32 UTC by Torbjorn Norbye
Modified: 2010-06-17 14:24 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Torbjorn Norbye 2010-05-12 15:32:05 UTC
If I have a class like this:

class Foo {
    function bar(): Void {
        println("baz");
    }
}

...and I format it, then I get this:

class Foo {
    function bar(): Void {
        println("baz");
    }

}

In other words, an extra newline before the closing }. This seems to happen with all classes.

I looked through the formatting options for Blank Lines and Blank Lines 2 but didn't see anything obvious to tweak this.

And if there -is- an option for it, I think the default should be the opposite - it should remove the empty line before the class closing bracket.

This only seems to happen with classes -- function bodies and object initialization blocks look correct already.
Comment 1 Anton Chechel 2010-05-13 11:26:24 UTC
Does Java formatter behave same on your computer?
Comment 2 Torbjorn Norbye 2010-05-15 05:59:51 UTC
No, the Java formatter does not behave that way -- it does not insert an extra newline there.
Comment 3 Anton Chechel 2010-05-20 16:53:16 UTC
Blank line before last brace is a special case of #186026. Also there are settings for class members in settings-editor-formatting-java fx-blank lines2. Please check it.

*** This bug has been marked as a duplicate of bug 186026 ***
Comment 4 Torbjorn Norbye 2010-05-20 18:05:42 UTC
This is still broken for me. If I format the test case in this issue, it will still insert a new line between the function and the end of the class.

There is no option to control this in "Blank Lines2", but it seems to be tied to the "After Function" setting in "Blank Lines". It by default is set to 1. If I change it to 0, then the newline between the function and the end of the class disappears, but of course this means that it will also remove newlines after all other functions, which I don't want.  I think this is a special case. If you want it controlled by a flag, there is a "After Class Header" setting (defaults to 0), perhaps you can add a "Before Class Footer" setting.  But I think it's simplest to just not add the "After Function" line count is it's the last function in an enclosing block like the class.
Comment 5 Anton Chechel 2010-05-20 19:12:56 UTC
Sounds reasonable. Will take a look tomorrow.
Comment 6 Alexandr Scherbatiy 2010-05-26 13:02:38 UTC
The issue is still reproduced in build netbeans-trunk-nightly-201005260001-javafx-windows.exe
Comment 7 Anton Chechel 2010-05-31 13:17:20 UTC
We agreed with reporter this is not an issue.
Blank lines should be kept inside class members only like Java formatter does it.
Comment 8 Alexandr Scherbatiy 2010-06-17 08:32:21 UTC
Ok. If reporter agrees with the issue it can be verified.
Comment 9 Torbjorn Norbye 2010-06-17 14:24:35 UTC
I'm confused by this:

"We agreed with reporter this is not an issue. Blank lines should be kept inside class members only like Java formatter does it."

This issue isn't about not removing newlines -- it's about a newline being INSERTED where it shouldn't be, right?