Bug 118136 - [refactoring] Introduce field
Summary: [refactoring] Introduce field
Status: RESOLVED DUPLICATE of bug 52791
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-26 12:13 EST by Thomas Singer CLA
Modified: 2005-11-28 12:10 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Singer CLA 2005-11-26 12:13:55 EST
At the moment it is relatively unconvenient: create a local variable, convert it to a field.

Also, the new 'Introduce Field' action should optionally replace the same code fragment from different methods.
Comment 1 Olivier Thomann CLA 2005-11-26 18:56:23 EST
Move to JDT/UI
Comment 2 Martin Aeschlimann CLA 2005-11-28 06:29:29 EST
I'm not sure if I understood what you suggest: You have an local variable and what it to become a field?
 -> There is already a refactoring 'Convert Local Variable to Field'

I don't see where you can replace similar code fragments. Please give an example.

Please reopen if I misunderstood the request.
Comment 3 Thomas Singer CLA 2005-11-28 07:25:54 EST
Example:

  public class Foo {
    private final Bar bar;

    public Foo(Bar bar) {
      this.bar = bar;
    }

    public void doSomething() {
      doSomethingElse(bar.getBazz());
    }

    public void doSomethingElse(Bazz bazz) {...}
  }

I want to introduce a field 'bazz' for 'bar.getBazz()'. Its not possible right now to do it in one step. Expected result (with constructor initialization):

  public class Foo {
    private final Bar bar;
    private final Bazz bazz;

    public Foo(Bar bar) {
      this.bar = bar;
      this.bazz = bar.getBazz();
    }

    public void doSomething() {
      doSomethingElse(bazz);
    }

    public void doSomethingElse(Bazz bazz) {...}
  }
Comment 4 Martin Aeschlimann CLA 2005-11-28 12:10:24 EST

*** This bug has been marked as a duplicate of 52791 ***