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.
This problem happens when you have a java file template that contains a simple section with method header. The header must be written on a single line (the method opening brace must be on the same line where the method signature is). See attachment an example of the template. You have to have a "Add New Line Before Brace" java editor option is enabled. Now when a user creates a file from the template, the code is reorganized and the brace is moved to the new line, but the guarded section is not expanded - so it is still only one line. Therefore the brace "moved" outside of the guarded block. This bug is similar to #66453.
Created attachment 28795 [details] Java file template
Is this issue really P2?
Yes, because people cannot use "Add New Line Before Brace" feature together with Visual Mobile Designer (VMD) and they are always suprised that it is generating wrong code. The problem is that I (as a developer of VMD) cannot workaround it programatically.
We have lot of reports about this issue...
OK, I take this since I've been digging around guarded sections code anyway these days.
fixed in http://java.netbeans.org/source/browse/java/src/org/netbeans/modules/java/IndentFileEntry.java?r1=1.14&r2=1.15 The isse relates to both simple and interiror sections. The fix transforms a single line guard to a multiline section: before public void m() {//GEN-LINE:head }//GEN-LINE:tail after public void m()//GEN-BEGIN:head {//GEN-END:head }//GEN-LINE:tail and a single line header to a multiline header section: before public void method2(int a) {//GEN-FIRST:METHOD2 // todo }//GEN-LAST:METHOD2 after public void method2(int a)//GEN-FIRST:METHOD2 {//GEN-HEADEREND:METHOD2 // todo }//GEN-LAST:METHOD2