Bug 210560 - 7.1.1, editor, java, Enter in empty method creates redundant closing curly bracket
7.1.1, editor, java, Enter in empty method creates redundant closing curly br...
Status: RESOLVED WORKSFORME
Product: editor
Classification: Unclassified
Component: Formatting & Indentation
7.1.1
PC Windows 7
: P2 (vote)
: 7.1.1
Assigned To: Dusan Balek
issues@editor
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-02 16:01 UTC by ptomasek
Modified: 2012-04-03 07:40 UTC (History)
0 users

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ptomasek 2012-04-02 16:01:22 UTC
Pressing Enter after the opening curly bracket at the beginning of an empty method which has the closing curly bracket already in place results into two closing curly brackets, which makes an incorrect Java code.

Steps to reproduce:

a) Create a new Java class file.
b) Write the below three lines of code.
c) Place the cursor at the end of line 2.
d) Press Enter.

Code (lines begin with line number):

1    public class A  {
2        public boolean execute() {
3        }

Expected result:

1    public class A  {
2        public boolean execute() {
3
4        }

Actual result:
1    public class A  {
2        public boolean execute() {
3
4        }
5        }
Comment 1 Dusan Balek 2012-04-03 07:15:11 UTC
The Bracket Completion is one of the features of the NetBeans Java editor, which from an incorrect Java code creates the syntactically correct one (see your test case). However, if you don't like this feature, you can turn it off via 'Tools -> Options -> Editor -> Code Completion -> Insert Closing Brackets Automatically'. Closing as WORKSFORME.
Comment 2 ptomasek 2012-04-03 07:40:17 UTC
Oh, I see. The indentation confused me.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo