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 173295 - Wrong indentation after applying hint
Summary: Wrong indentation after applying hint
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker with 2 votes (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-29 16:20 UTC by Jiri Prox
Modified: 2016-07-07 07:18 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Prox 2009-09-29 16:20:05 UTC
Product Version: NetBeans IDE 6.8 Beta (Build 200909281634)
Java: 1.6.0_16; Java HotSpot(TM) Client VM 14.2-b01
System: Linux version 2.6.24-23-generic running on i386; UTF-8; en_US (nb)

The indentation is wrong when hint is applied in switch statement.

Steps to reproduce:
0) keep default formatting setting
1) have a code:
    public void test() {
        int x = 2;
        switch (x) {
            case 1:
                System.getProperties();
        }
    }

2) apply hint "assign return value to new variable"
->
    public void test() {
        int x = 2;
        switch (x) {
            case 1:
        Properties properties = System.getProperties();
        }
    }
Comment 1 cezariusz 2015-04-22 14:21:10 UTC
Product Version: NetBeans IDE Dev (Build 201504210001)
Java: 1.8.0_45; Java HotSpot(TM) 64-Bit Server VM 25.45-b02
Runtime: Java(TM) SE Runtime Environment 1.8.0_45-b14
System: Windows 7 version 6.1 running on amd64; UTF-8; pl_PL (nb)

The issue is still valid for 8.0.2 version!

My test case:

public class EnumCodeCompletion {

    public enum Sample {
        ONE, TWO, THREE
    }

    void demo(Sample number) {
        switch (number) {
            case ONE:
                System.out.println("One");
                number.name();
                break;
            case TWO:
                System.out.println("Two");
                break;
        }
    }

}

Invoke hint "Assign Return Value To New Variable" on the line "number.name();" and you will get:

    void demo(Sample number) {
        switch (number) {
            case ONE:
                System.out.println("One");
        String name = number.name();
                break;
            case TWO:
                System.out.println("Two");
                break;
        }
    }
Comment 2 Martin Balin 2016-07-07 07:18:27 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss