Bug 47712

Summary: [move method][refactoring] Move refactoring should move private methods
Product: [Eclipse Project] JDT Reporter: Eugene Kuleshov <ekuleshov>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: ASSIGNED --- QA Contact:
Severity: enhancement    
Priority: P4 CC: christof_marti, deepakazad, eclipse, erlend.k, mlists, reprogrammer
Version: 3.0   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:

Description Eugene Kuleshov CLA 2003-11-28 10:32:43 EST
Move refactoring should move private methods used in the selected block to the
target class if such methods only called from the selected block.

There could be some issues in case if these methods are using fields of the
source class, but I believe the can be resolved the same as references from the
selected block.
Comment 1 Dirk Baeumer CLA 2003-12-01 04:14:09 EST
Moving things for free isn't the right thing to do. The only enhancement I can 
think of adding a button to compute all dependencies and let the user decide 
what to do with this.
Comment 2 Eugene Kuleshov CLA 2003-12-01 10:28:53 EST
Ok. Let me rephrase my bug.

Eclipse should analyse if there are provate methods that only called from the
selected block and SUGGEST to move such methods into the target too.

Otherwise we are having the following situation.

-----
  // Source code
  {
     ...
     SomeClass b;
     privateMethod( b)
     ...
  }

  private privateMethod( SomeClass b) {
    ...
  }
-------

changed to the following. Notice "this"!

-------
     b.newMethod( this, b)
-------

  and result is broken anyway because privateMethod() can't be called from
SomeClass.
Comment 3 Christof Marti CLA 2005-04-07 11:52:46 EDT
Moving multiple members to a field's type often occurs when splitting an
existing class.

Using individual move operations does not have the same result, unless the
dependencies among the moved members form a tree and one moves them depth-first,
otherwise a moved method might need an additional parameter, pointing back to
its original containing type.
Comment 4 Martin Aeschlimann CLA 2006-06-19 09:49:12 EDT
It would be good to analyse a method if it does any access to the instance and use 'move static method' if possible