Bug 263889 - [quick fix] Create field/variable quick fix should reuse existing declarations
Summary: [quick fix] Create field/variable quick fix should reuse existing declarations
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-05 20:12 EST by Mirko Raner CLA
Modified: 2023-03-12 01:57 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.