Bug 263889

Summary: [quick fix] Create field/variable quick fix should reuse existing declarations
Product: [Eclipse Project] JDT Reporter: Mirko Raner <mirko>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: ASSIGNED --- QA Contact:
Severity: normal    
Priority: P3 CC: b.michael, daniel_megert
Version: 3.4.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug

Description Mirko Raner CLA 2009-02-05 20:12:01 EST
Build ID: M20080911-1700

IntelliJ IDEA 8 offers a helpful refactoring that moves the declaration of an existing local variable when the variable is used outside its scope. For example:

    if (list.isEmpty())
    {
        boolean empty = true;
        //...
    }
    if (empty)
    {
        ...
    }

The compilation problem caused by 'empty' being used in the second if statement offers a number of quick-fixes, but moving the declaration into scope is not currently among them. The proposed refactoring should move the declaration in front of the first if block but should leave the assignment where it was. It might also be necessary to add a default initialization for the declaration:

    boolean empty = false;
    if (list.isEmpty())
    {
        empty = true;
        //...
    }
    if (empty)
    {
        ...
    }

This refactoring would be slightly different from most of the other existing refactorings because it also searches other scopes in addition to the current scope to come up with a content assist suggestion.
Comment 1 Eclipse Genie CLA 2020-12-18 03:31:46 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 2 Eclipse Genie CLA 2023-03-12 01:57:45 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.