modeller
modeller

Reputation: 3850

In intelliJ, how to move an method to an implementing class of an interface?

I am using intelliJ 2016.2.1.

I have a method foo() in main class Test:

class Test {
   IService iService;

   foo(){...}

}

IService is an interface, it has one implementing class ServiceImpl. When I put caret on foo, and select move, intelliJ only allows me to select IService. But I actually want ServiceImpl as move destination.

And if I continue the move, intelliJ will put the method implementation inside the interface IService. But I want to have an declaration there.


Question: How do I refactor foo(), to move its method implementation into ServiceImpl, and method declaration in IService?

Upvotes: 2

Views: 1450

Answers (1)

yole
yole

Reputation: 97138

After you move the method to IService, use Refactor | Push Members Down... to move it to ServiceImpl.

Upvotes: 5

Related Questions