Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 76926

Summary: Add new CDI parameter to consructor from field. [refactoring]
Product: [Eclipse Project] JDT Reporter: Paul Hammant <paul>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: enhancement    
Priority: P3 Keywords: helpwanted
Version: 3.0.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Paul Hammant CLA 2004-10-25 08:08:17 EDT
This is a new refactoring operation.

Notes - 
  SDI = Setter Depenency Injection
  CDI = Constructor Depenency Injection
Both as defined in http://www.martinfowler.com/articles/injection.html 

A member variable/field can have a Constructor Dependency Injection parameter
added for it. The Constructors can be changed en masse, or duplicated. Field can
optionally go final. Consider:

class Apple {
  final Orange orange;
  Banana banana;
  public Apple(Orange o) {
    orange = o;
  }
  public Apple() {
    orange = new DefaultOrange();
  }
}

if banana were selected, and the 'add CDI parameter to ctor' were actioned, the
result would be:

class Apple {
  final Orange orange;
  final Banana banana;
  public Apple(Orange o, Banana banana) {
    orange = o;
    this.banana = banana;
  }
  public Apple(Banana banana) {
    orange = new DefaultOrange();
    this.banana = banana;
  }
}
Comment 1 Jerome Lanneluc CLA 2004-10-25 09:56:41 EDT
Moving to JDT UI for comments.
Comment 2 Dirk Baeumer CLA 2004-10-26 05:26:32 EDT
Parts of this can currently be done using change method signature. 

Time permitted.
Comment 3 Denis Roy CLA 2009-08-30 02:18:18 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.