2

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}
5
  • 1
    It's not obvious to see what exactly you try to achieve. Could you replace your pseudo-code by actual Java code to see what is meant by the above? Commented May 16, 2011 at 7:17
  • @Lukas - it's quite obvious: the main method has some calls to other methods (on the same class) and the plugin shall arrange the methods in the same order as they are called in the main methods body. I just wonder which scenarios/contexts would benefit from such a formatter. Academic use? Commented May 16, 2011 at 7:22
  • @Andreas_D - I am looking at this functionality as my methods have become too large. And its a pain to scroll through up and down when I can easily go to the next method by scrolling down instead of going back to the main method and Ctrl clicking it. Hope this makes it clear.. Commented May 16, 2011 at 8:36
  • (1) Outline View, (2) make methods smaller, (3) invent more classes. I really thought it was for homework/assignements for courses... Commented May 16, 2011 at 9:30
  • I've always done this manually. You usually have the problem of sub-methods not in the main method calling sequence to deal with. Commented May 16, 2011 at 16:03

4 Answers 4

5

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.

Sign up to request clarification or add additional context in comments.

4 Comments

I knew that I read about that exact idea somewhere but couldn't find it. +1
+1 - cool, but only to support clean coding, not to help with growing methods and classes (which is aheneo's actual problem ;) )
I think it is though. He has large methods, and want to be able to follow the flow as easy as possible by only scrolling down. I'd say that would entail sorting the methods in access order.
Here is a direct link to the documentation: wiki.eclipse.org/Recommenders/CleanCodeMethodSorter
1

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.

Comments

0

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

Comments

-1

Press Ctrl+I to set your code in Eclipse.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.