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 207090 - [Inline] Improve selection
Summary: [Inline] Improve selection
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 7.1
Hardware: All All
: P4 normal (vote)
Assignee: Ralph Ruijs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-09 20:48 UTC by muellermi
Modified: 2012-04-13 09:51 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 muellermi 2012-01-09 20:48:24 UTC
Product Version = NetBeans IDE 7.1 (Build 201112051121)
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 1.7.0_02
Runtime = Java HotSpot(TM) 64-Bit Server VM 22.0-b10

according to http://wiki.netbeans.org/NewAndNoteworthyNB71#Inline
in calculatePrice the assignement of basePrice should be removed and all other occurenced should be replaced by "getBasePrice"

    double BASEPRICE = 2000;
    
    public double calculatePrice() {
        double basePrice = getBasePrice();
        if (basePrice > 1000) {
         return basePrice * 0.95;  
        }else{
         return basePrice * 0.98;      // mark this line and choose refactoring -> inline
        }
    }

    private double getBasePrice() {
        return BASEPRICE;
    }

But, NB alerts, a method with multiple return statements cannot be refactored by inline
Comment 1 Ralph Ruijs 2012-01-10 13:32:40 UTC
Selecting a whole line in the method (I think this is what you meant with mark) and then choose Inline, will start the Inline Method Refactoring for calculatePrice().

To inline the temporary variable basePrice; place the cursor on the variable name or select the variable name and choose Refactor->Inline...

I changed the bug to improve the selection, as selecting the whole variable declaration statement, incorrectly starts Inline Method.

Thanks for the report.
Comment 2 Ralph Ruijs 2012-04-11 12:31:42 UTC
Changeset: f07629ac63a5
Author:    Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org>
Date:      2012-04-11 14:30
Message:   
Issue #207090 - [Inline] Improve selection
Comment 3 Quality Engineering 2012-04-13 09:51:54 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/f07629ac63a5
User: Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org>
Log: Issue #207090 - [Inline] Improve selection