ahaneo
ahaneo

Reputation: 187

eclipse format java source code based on method calls

I have written a class with many different methods. I am looking for a plugin which witll arrange the code based on the calls in the main method

For example my general structure might be

{main method (call method b, call method d, call method a)
method a,
method b,
method c,
method d}

I want the plugin to format my source code as

{main method (call method b, call method d, call method a)
method b,
method d,
method a,
method c}

Upvotes: 2

Views: 666

Answers (4)

Marcel
Marcel

Reputation: 187

The clean code method sorter is currently in development. You may check out http://wiki.eclipse.org/Recommenders/CleanCodeMethodSorter for current progress and installation instructions of the current prototype. It might be a bit rough at some places. Feel free to report any unwanted behavior to the Eclipse Bugzilla (details on the wiki page).

Best, Marcel

Upvotes: 0

yogi
yogi

Reputation: 1

Press Ctrl+I to set your code in Eclipse.

Upvotes: -1

VonC
VonC

Reputation: 1329942

I didn't see any plugin able to provide that kind of sort order, depending not on the nature of the Java element (as shown in the Eclipse preferences under "Java / Appearance / Menbers Sort Order"), but on the order of usage in a given method.

That wouldn't be very convenient, since you wouldn't be sure that kind of ordering would be always respected by other developers, unless they have that specific format plugin in their own Eclipse installation.

The ability to directly access any method with CTRL+click or through the outline view is generally enough.

Upvotes: 1

Henrik Gustafsson
Henrik Gustafsson

Reputation: 54338

If I understand you correctly, I think there's a GSOC project for Code Recommenders to do exactly that; see this bug and this blog post. You might be able to get some clues from there.

Upvotes: 5

Related Questions