Bug 47712 - [move method][refactoring] Move refactoring should move private methods
Summary: [move method][refactoring] Move refactoring should move private methods
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: PC All
: P4 enhancement with 4 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-11-28 10:32 EST by Eugene Kuleshov CLA
Modified: 2013-12-11 08:07 EST (History)
6 users (show)

See Also:


Attachments

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