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 210971 - Invert Boolean Writes "!" Before All Return Values Of All Methods
Summary: Invert Boolean Writes "!" Before All Return Values Of All Methods
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 7.2
Hardware: PC Windows Vista
: P2 normal (vote)
Assignee: Jan Becicka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-10 18:08 UTC by MackSix
Modified: 2012-04-18 21:27 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Test covering last usecase (3.50 KB, patch)
2012-04-16 08:21 UTC, Jan Becicka
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description MackSix 2012-04-10 18:08:51 UTC
If I select a method and use Refactor>>Invert Boolean, all methods with a return value have "!" written before their return value.

BEFORE:

public class NewClass {
    boolean b = true;
    
    public boolean someMethod() {
        return true;
    }
    
    public String methodMethod2() {
        return "Hello World!";
    }
    
    public boolean crazyOtherMethod() {
        return b;       
    }
    
    public int returnInt() {
        return 1099;
    }
    
    public Object returnObj() {
        return this;
    }
}


AFTER INVERT BOOLEAN ON someMethod():

public class NewClass {
    boolean b = true;
    
    public boolean someMethod() {
        return false;
    }
    
    public String methodMethod2() {
        return !"Hello World!";
    }
    
    public boolean crazyOtherMethod() {
        return !b;       
    }
    
    public int returnInt() {
        return !1099;
    }
    
    public Object returnObj() {
        return !this;
    }
}
Comment 1 Jan Becicka 2012-04-11 08:15:37 UTC
P1 if reproducible
Comment 2 Jan Becicka 2012-04-11 13:35:34 UTC
Changeset: 23976537b2a2
Author:    Jan Becicka <jbecicka@netbeans.org>
Date:      2012-04-11 15:22
Message:   
Issue #210971 - Invert Boolean Writes "!" Before All Return Values Of All Methods
Comment 3 Quality Engineering 2012-04-13 09:49:22 UTC
Integrated into 'main-golden', will be available in build *201204130400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/23976537b2a2
User: Jan Becicka <jbecicka@netbeans.org>
Log: Issue #210971 - Invert Boolean Writes "!" Before All Return Values Of All Methods
Comment 4 MackSix 2012-04-14 07:48:49 UTC
Now it turns b into !$enclosing.b in the 3rd method when I invert b to false. If I rename the variable to c when prompted in the inversion process, it works. See below.

public class NewClass {
    
    boolean b = false;

    public boolean someMethod() {
        return true;
    }

    public String methodMethod2() {
        return "Hello World!";
    }

    public boolean crazyOtherMethod() {
        return !$enclosing.b;       
    }

    public int returnInt() {
        return 1099;
    }

    public Object returnObj() {
        return this;
    }
}

Product Version: NetBeans IDE Dev (Build 201204130400)
Java: 1.7.0_03; Java HotSpot(TM) Client VM 22.1-b02
System: Windows Vista version 6.0 running on x86; Cp1252; en_US (nb)
Comment 5 Jan Becicka 2012-04-16 08:21:33 UTC
Created attachment 118306 [details]
Test covering last usecase
Comment 6 Jan Lahoda 2012-04-18 09:36:48 UTC
http://hg.netbeans.org/jet-main/rev/ceb3b8ba0018
Comment 7 Quality Engineering 2012-04-18 21:27:48 UTC
Integrated into 'main-golden', will be available in build *201204181547* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/ceb3b8ba0018
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #210971: rewrite $this.field=>$this.field should work also when $this is implicit and the result is actually resolvable. Also passing constraints to declarative JavaFix on creation.