How to refactor a static inner class to a top level class in Eclipse?

This is so easy I can’t believe I missed it:

With the cursor anywhere within the inner type, right click and select:
Refactor -> Convert Member Type to Top Level...

(There is no shortcut in the default settings)

This automatically extracts the inner type, and places it in it’s own file, in the same package and directory as the outer type.

Update

In later versions of Eclipse this refactoring has been renamed “Move Type to New File”

Leave a Comment