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 72396 - GuardedSestion vs. Add New Line Before Brace
Summary: GuardedSestion vs. Add New Line Before Brace
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: Jan Pokorsky
URL:
Keywords:
Depends on:
Blocks: 72182
  Show dependency tree
 
Reported: 2006-02-08 12:55 UTC by David Kaspar
Modified: 2006-10-23 16:40 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Java file template (415 bytes, text/plain)
2006-02-08 12:57 UTC, David Kaspar
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Kaspar 2006-02-08 12:55:24 UTC
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.
Comment 1 David Kaspar 2006-02-08 12:57:38 UTC
Created attachment 28795 [details]
Java file template
Comment 2 Jan Becicka 2006-03-17 18:48:31 UTC
Is this issue really P2?
Comment 3 David Kaspar 2006-03-20 12:33:45 UTC
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.
Comment 4 Lukas Hasik 2006-07-25 10:58:53 UTC
We have lot of reports about this issue...
Comment 5 Jan Pokorsky 2006-07-26 13:16:59 UTC
OK, I take this since I've been digging around guarded sections code anyway
these days.
Comment 6 Jan Pokorsky 2006-07-26 14:17:39 UTC
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