I am working on understanding a project which was already created by someone else. It did not followed a proper coding method (no comments and so on). I'm finding it difficult to find where a method is used during the use of the app .So ideally I want to track how each method is used and when it's called while manipulating the applciation . I've already searched the problem here and nothing worked for me. So can anyone please help me out. I am using Intellij btw . Thank you .
CodePudding user response:
You can use the debugger of Intellij, that's a really cool tool and besides your problem, it can be used to find bugs in your code.
The basic and easiest way to use it is:
- Add breakpoints on lines where you want the application to stop just before executing that line. You can add as many breakpoints as you want and in as many files you want. To add a breakpoint, just click on the empty space beside the line numbering on the left side of the editor window.
- then turn on the debugger from the
run
menu orShift F9
. - then use the
step over
option orF8
to jump to the next breakpoint from the current location. - In your case, you can add a breakpoint in the method for which you wanna test, and then see if the program approaches that particular breakpoint during execution.
You can read the more detailed documentation on debugging from this link: Complete debugging guide: Jetbrains.
Hope this helps to solve your issue.
CodePudding user response:
use Find Usages for the method to see where it is used
use a method call hierarchy to see which methods invoke this method
use method breakpoint to stop in debugger any time the method is invoked