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 70208 - [Introduce Var] Variable usually put in the wrong place
Summary: [Introduce Var] Variable usually put in the wrong place
Status: RESOLVED DUPLICATE of bug 60103
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: issues@java
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-11 00:02 UTC by Jesse Glick
Modified: 2005-12-12 20:16 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 Jesse Glick 2005-12-11 00:02:23 UTC
It seems that whenever I use the Introduce Variable refactoring, the new
variable gets put in an inappropriate location. It is apparently always put at
the start of the current method, which almost never works. E.g.

void m() {
    // some stuff..
    if (test) {
        // some stuff...
        String x = ...;
        use(x + ".suffix");
    }
}

Now select 'x + ".suffix"' and use Introduce Var and call it y. You will get
something like

void m() {
    String y = x + ".suffix";
    // some stuff..
    if (test) {
        // some stuff...
        String x = ...;
        use(y);
    }
}

which of course does not compile.

The refactoring needs to examine the expression for all local variables and
introduce the new variable sometime after the definition of the last used local
variable.
Comment 1 Jan Becicka 2005-12-12 07:06:43 UTC

*** This issue has been marked as a duplicate of 60103 ***