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 239452 - [Anonymous to member] breaks indent
Summary: [Anonymous to member] breaks indent
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 8.0
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-13 09:41 UTC by ssazonov
Modified: 2014-10-18 05:10 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
options1 (62.75 KB, image/png)
2013-12-13 09:41 UTC, ssazonov
Details
options2 (81.20 KB, image/png)
2013-12-13 09:41 UTC, ssazonov
Details
before/after (135.05 KB, image/png)
2013-12-13 09:42 UTC, ssazonov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ssazonov 2013-12-13 09:41:08 UTC
1. Create simple java class:

package anonymousToMember;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JButton;

public class ClassA {

    public void m1() {
        JButton btn = new JButton();
        btn.addMouseListener(new MouseListener() {

            @Override
            public void mouseClicked(MouseEvent e) {
                System.out.println("Clicked");
            }

            @Override
            public void mousePressed(MouseEvent e) {
                System.out.println("Pressed");
            }

            @Override
            public void mouseReleased(MouseEvent e) {
                System.out.println("Released");
            }

            @Override
            public void mouseEntered(MouseEvent e) {
                System.out.println("Entered");
            }

            @Override
            public void mouseExited(MouseEvent e) {
                System.out.println("Exited");
            }
        });
    }
}

2. Set Options according attached images (options1, options2)

3. Right click "MouseListener" and from pop-up menu select Refactor > Convert Anonymous to Member...

>> Anonymous class has been converted to member but its indent has been broken

Product Version: NetBeans IDE Dev (Build 201312110002)
Java: 1.7.0_45; Java HotSpot(TM) 64-Bit Server VM 24.45-b08
Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b18
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
Comment 1 ssazonov 2013-12-13 09:41:37 UTC
Created attachment 143136 [details]
options1
Comment 2 ssazonov 2013-12-13 09:41:54 UTC
Created attachment 143137 [details]
options2
Comment 3 ssazonov 2013-12-13 09:42:15 UTC
Created attachment 143138 [details]
before/after
Comment 4 Svata Dedic 2014-02-20 13:56:26 UTC
The source is generated +- correctly, that is:

public class ClassA {

    public void m1() {
        JButton btn = new JButton();
        btn.addMouseListener(new MouseListenerImpl());
    }

    private static class MouseListenerImpl implements MouseListener {

        public MouseListenerImpl() {
        }

        @Override
            public void mouseClicked(MouseEvent e) {
                System.out.println("Clicked");
            }

        @Override
            public void mousePressed(MouseEvent e) {
                System.out.println("Pressed");
            }

        @Override
            public void mouseReleased(MouseEvent e) {
                System.out.println("Released");
            }

        @Override
            public void mouseEntered(MouseEvent e) {
                System.out.println("Entered");
            }

            @Override
            public void mouseExited(MouseEvent e) {
                System.out.println("Exited");
            }
    }
}


Each copied method is then reindented (separately, one method region at a time), using Indent.reindent() starting from the @Override. However the indenter computes the desired methods indent to 12.
Comment 5 Dusan Balek 2014-04-25 09:38:08 UTC
Fixed in jet-main.

http://hg.netbeans.org/jet-main/rev/2447207afb9e
Comment 6 Quality Engineering 2014-04-27 01:21:39 UTC
Integrated into 'main-silver', will be available in build *201404270001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/2447207afb9e
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #239452: [Anonymous to member] breaks indent - fixed.
Comment 7 Quality Engineering 2014-10-18 05:10:40 UTC
Integrated into 'main-silver', will be available in build *201410180001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/23affa43cc5f
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #239452: [Anonymous to member] breaks indent - fixed.