user3481644
user3481644

Reputation: 440

Create a list of java methods that ultimately call a specified method

I've been tasked to find all of the methods in a large Java application which ultimately call a specific method that needs to be refactored.

To clarify, if the target method is "fixme", and "fixme" is called by "a", "b", and "c", but "a" is called by "d" and "e"; "b" is called by "d", "f", "g", "h", "i"; and "c" is called by "j" and "k". Then "d" is called by ..., etc. So we have

k calls c calls fixme
g calls b calls fixme

and so on.

The depth of these call "chains" can get pretty deep and there several dozen that directly call "fixme", so a manual solution will take a while. And this is not going to be the only refactoring task.

So - I'm looking for a tool, or strategy, that can do this work while I lazily watch.

I am aware of of IDEs such as Eclipse that lets you find references to methods, but those work one method at a time. Executing the code with trace messages requires full code coverage which is not feasible (nor reliable as I could miss one). I'm really looking for some kind of static code analyzer with this kind of feature.

Upvotes: 0

Views: 53

Answers (1)

MTilsted
MTilsted

Reputation: 5520

Eclipse can do that. In the eclipse call view (CTRL+ALT+H when the cursor is on the method) you can expand each node, to see the full call stack.

When all is expanded, right click on the top node and select "Copy expanded hierarchy".

Only problem with this solution is that I could not find a way to auto-expand it, so you have to click once for each call.

Upvotes: 1

Related Questions