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 254748 - "Introduce Variable" ignores function usages in previous lines
Summary: "Introduce Variable" ignores function usages in previous lines
Status: NEW
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Model (show other bugs)
Version: 8.1
Hardware: PC Solaris
: P3 normal (vote)
Assignee: Alexander Simon
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-26 09:46 UTC by soldatov
Modified: 2016-10-31 11:22 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 soldatov 2015-08-26 09:46:58 UTC
Java sample:
- select latest foo(1), press Alt+Shift+V and press OK
==> IDE replaces
===============================================================
package javaapplication3;

public class JavaApplication3 {

    public static int foo(int x) {
        return 2 * x;
    }

    public static void main(String[] args) {
        int x = foo(1) + foo(2);
        if (true) {
            int y = foo(2) + foo(1);
            int z = foo(1) + foo(1); // <-- replace latest foo(1)
        }
    }
    
}
===============================================================
on
===============================================================
    public static void main(String[] args) {
        final int foo = foo(1); // <-- new line
        int x = foo + foo(2); // <-- replaced
        if (true) {
            int y = foo(2) + foo; // <-- replaced
            int z = foo + foo; // <-- replaced (2 times)
        }
    }

===============================================================
In C++ IDE will replace
===============================================================
int foo(int x) {
    return 2 * x;
}

int main() {
    int x = foo(1) + foo(2);
    if (true) {
        int y = foo(2) + foo(1);
        int z = foo(1) + foo(1); // <-- replace latest foo(1)
    }
}
===============================================================
on
int main() {
    int x = foo(1) + foo(2);
    if (true) {
        int y = foo(2) + foo(1);
        int foo = foo(1); // <-- new line
        int z = foo(1) + foo; // <-- replaced
    }
}
===============================================================