JnRouvignac / AutoRefactor

Eclipse plugin to automatically refactor Java code bases
Other
175 stars 37 forks source link

New refactoring - Meta - Suggest methods that can be extracted #8

Open JnRouvignac opened 11 years ago

JnRouvignac commented 11 years ago

If possible, improve or build on the JDT extract method.

Extract method across type of variables, types, and casts

It would be nice to provide Extract method refactoring across:

Probably too hard to do, would be to move statements together, but this might require deep inter procedural analysis. Maybe simple arithmetics or boolean expressions that all live in the current method body can be moved like this.

Consecutive lines threshold

Also, if we hit specific thresholds: If more than X (10? 20? 30?) consecutive lines of code are only here to output one variable: then we suggest to extract a method.

Eclipse's JDT Extract Method

See info about Eclipse's JDT Extract Method here:

For development, see:

Example tests with in and out folders:

JnRouvignac commented 11 years ago

It is possible to programatically call Eclipse's refactorings: read the following javadocs: http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.jdt.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fjdt%2Fcore%2Frefactoring%2FIJavaRefactorings.html

So once potential refactorings have been found, it should be possible to do a few simple refactorings to extract local variables and move them around, then use the Eclipse "Extract Method" refactoring.