I'm on a new project and it's insanely complex. I ...
# getting-started
c
I'm on a new project and it's insanely complex. I almost wish I can print out method names as they are called in order to help me see what methods are called on a button click for example. Is there any easy way to do that? So far I'm manually going in and doing multicursor search for
fun
and then putting a log statement. It works just takes a while.
j
Not efficient but you can throw an exception and use the stackstrace
a
is it a JVM project? You could try adding tracing using the Java agent https://opentelemetry.io/docs/zero-code/java/agent/
👍 1
c
In IntelliJ, a few things that could be helpful: On a method: • Call hierarchy: recursive usage search, finds all methods calling this function, then all methods calling them, etc • Method hierarchy: recursive function declaration search On a variable/parameter/etc: • Data-flow from here: shows all values that are impacted by the one you selected • Data-flow to here: shows all values that impact the one you selected Using these tools, you can easily navigate through complex method calls (as long as they don't use magic, like code generation or reflection, in which case god save you)
Other than that, stepping through with a debugger should work fairly well, though it may be slow
c
i wonder if i could just use structural search and replace. but let me take a look at the other options above
c
You can also create logging breakpoints, it's usually more convenient than temporary logging statements because you can just remove/disable them without having to recompile, and you can place them in library code. For example, I use them to log the actual generated SQL requests that are sent to the DB
today i learned 1
c
oooh. jake whartons Hugo looks like exactly what i want
e
On the JVM, one don’t actually need to throw an exception to capture a stack trace. It’s enough to instantiate an exception (e.g.,
Exception()
), pass it around through methods calls as needed, and then later call
getStackTrace()
on it. If a dev does not want to throw