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 158926 - javafx script editor automatically reformats entire file on newline, and does so quite badly
Summary: javafx script editor automatically reformats entire file on newline, and does...
Status: VERIFIED FIXED
Alias: None
Product: javafx
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Anton Chechel
URL:
Keywords:
Depends on:
Blocks: 155841
  Show dependency tree
 
Reported: 2009-02-21 01:57 UTC by stuart_marks
Modified: 2009-03-10 15:40 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
reference JavaFX Script source file (970 bytes, text/plain)
2009-02-21 01:58 UTC, stuart_marks
Details
JavaFX Script source file, malformatted (936 bytes, text/plain)
2009-02-21 01:59 UTC, stuart_marks
Details

Note You need to log in before you can comment on or make changes to this bug.
Description stuart_marks 2009-02-21 01:57:24 UTC
The JavaFX Script code reformatter is run most of the time (if not every time) you press ENTER to add a newline to a .fx
file. This wouldn't be so bad, except that there are a large number of cases where the formatting engine gets things
terribly wrong. It would be one thing if I had to clean up a file after invoking reindentation explicitly.
Unfortunately, reformatting occurs automatically and silently and very frequently during a normal editing session.

The main point of this bug report is that the reformatting occurs automatically, silently, and frequently, and there
appears to be no way to turn it off.

This forces me to clean up after the editor, even after brief editing sessions with apparently innocuous changes. For
example, if I were to add a line or two of whitespace, or add some lines to doc comments, I will have to run "diff" over
the resulting file and then manually undo all of the changes that the editor has made reformatting the file. I hope you
can see that this is incredibly irritating. This makes using NetBeans almost unusable for me, so I've filed this at a
relatively high priority.

If there is a way to turn automatic formatting off, I would love to hear about it.

This occurs in the NetBeans+JavaFX+SDK installer build, Hudson #24, available at the Sun internal site:

http://jeevez.russia/hudson/job/JavaFX_NB_Plugin_Franca_NB_65_fixes_promoted_SDK_installer/

But I believe this corresponds to the JavaFX 1.1 release that's publicly available.

I believe the IDE should NEVER reformat source files as a matter of course. Even if the formatter were working well, I'm
don't think it should ever be run automatically and silently. There are too many special cases in real code where
developers will need to use odd indentation to make the code clearer. The IDE will never get these cases correct. I
would be very, very angry if the IDE were to "correct" the indentation of such code for me silently and automatically,
when I would consider it incorrect.

I will attach two files:

(a) Main.fx.REF, which contains JavaFX Script indented in a particular, though not unconventional way; and

(b) Main.fx, which contains the same script after being reformatted by the JavaFX editor.

The example code itself isn't very interesting, but it is all based on real code that my team and I have been working on.

To see the reformatting happen, copy Main.fx.REF to Main.fx, and open Main.fx in the editor. Position the cursor at the
beginning of the line marked (0), just before "public class Main". Press ENTER. A newline will *not* be inserted, which
is a bug. In addition, the entire file will be reformatted, introducing a variety of indentation errors into the file.
The errors are as follows, and occur at the lines in the file marked (n).

(1) Whitespace before colon (:) is removed. Although I personally don't like this style, some developers like the colons
in their declarations to line up. Reformatting breaks this.

(2) The second line of a multi-line comment is shifted left by one space.

(3) A variable initializer split across multiple lines is joined inappropriately.

(4) If/else lines without braces are deindented one level.

(5) Two extra newlines are added following the above.

(6) Variable initializer with "as Integer" cast is split inappropriately. Two extra newlines are added following.

(7) Assignment statement with a large indented multi-line expression following is deintended inappropriately.
Comment 1 stuart_marks 2009-02-21 01:58:30 UTC
Created attachment 77213 [details]
reference JavaFX Script source file
Comment 2 stuart_marks 2009-02-21 01:59:05 UTC
Created attachment 77214 [details]
JavaFX Script source file, malformatted
Comment 3 stuart_marks 2009-02-21 02:21:08 UTC
There are a variety of formatting issues already in the database. Many of them seem quite similar to the issues I've
noted here, but not exactly. I do note that (6) seems identical to issue #157500.

However, please consider this issue primarily to be about the automatic reformatting, and not about any specific
formatting issue.
Comment 4 Adam Sotona 2009-03-09 14:12:46 UTC
automatic reformat is disabled now
Comment 5 Alexandr Scherbatiy 2009-03-10 15:40:27 UTC
Created separate issues:
issue 160017
issue 160018
issue 160020