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.
I tried formatting some of my source files, and all my "breather" lines (extra newlines inserted between variables, before return statements, and around blocks like if statements) were removed! Here's an example -- take the following class: class Foo { public var foo; public var bar; function bar(): Void { println("baz"); if (false) { true } true } } If I reformat this, I end up with: class Foo { public var foo; public var bar; function bar(): Void { println("baz"); if (false) { true } true } } I realize that there may be options which says exactly how many newlines to separate members by, and that's why the properties were moved together; but certainly inside a method I don't think newlines should be removed (collapsed from >1 to 1 is fine, but going from 1 to 0 is not). I think other formatters (maybe even the NetBeans Java one) generally takes the approach that it's okay to -add- newlines according to the options, and it's okay to reduce the number of newlines according to the options (so if you have 3 newlines between two functions, it gets changed to 2), but that you generally always leave at least one newline IF the user had added it.
By the way: I've formatted a number of complex files today and looked at the diffs, and this is the last blocker before I can start using the formatter. There are some other minor things here and there which I'll file but none of them are a big deal, e.g. they are infrequent scenarios where I can easily undo the change myself etc.
Tor, This is exactly same behavior as for Java. I see this can be problem, but I am not sure it is P2 level issue. Please reevaluate.
> "This is exactly same behavior as for Java" That's not true. Here's the equivalent sample code in Java: public class Foo { public int foo; public int bar; void bar() { System.out.println("baz"); if (false) { return; } return; } } When I reformat this, with a brand new userdir (so no modified formatting settings), it makes only one formatting change: it inserts a new line right inside the class body. It does NOT remove my extra newlines. If I remove the newlines myself, it does not insert them (e.g. this is not a case of my sample having corresponded exactly to where it wants newlines). It's definitely preserving extra newlines when reformatting, so it leaves the code nice and "airy". With the FX formatter all the code gets condensed.
fixed http://hg.netbeans.org/javafx/rev/2cc411b51dc3 Tor, we decided to provide desired by you behavior only for block expressions: function bodies, conditional expressions, loops, etc. - all except class members. This how it is done in Java. It is not difficult for me to do it for class members as well but it will differs from java formatter. Please test it. What do you think?
*** Bug 186023 has been marked as a duplicate of this bug. ***
YAY! I'll rebuild and test right away!
Thank you! It's much better! It looks like it's collapsing not just class members but sequence members as well. Here's a code snippet: def actions = [ if (canCopy) { Action { displayName: "Copy" action: function() { selection.copy(); } } } else { null }, Action { displayName: "Delete" action: function() { selection.<<delete>>(); } } // etc ] Here there are if blocks etc inside of a sequence. When formatted, these get collapsed. Was that intentional?
No, it was not intentional. I just commited fix: http://hg.netbeans.org/javafx/rev/9f90359f8d24 Rebuild it and please test again. :) PS: I also don't like the fact it removes blank space right after imports. Tomorrow will take a look on it.
Yesssssss!!!! Works beautifully now! I have added newlines in many places to "group" related sets of attributes, and it's removing those, but you are correct -- the Java formatter does that to my fields too. I think I'll just have to learn to have them all right next to each other. That's not a big deal. I'm really happy! Thank you! And thank you for getting this into 6.9, I was afraid it wasn't going to make it :)
verified in netbeans-trunk-nightly-201005210001-javafx-windows.exe
Integrated into release69 http://hg.netbeans.org/javafx/changeset/d5e2235b4f4f - Anton
Verified in NB 6.9 RC1