How to set method breakpoint from plugin using class and method name only?
From within my plugin, I want to be able to set a breakpoint on a specific method within the code that is being debugged. The catch is that I don't know the file or line number containing the method -- the only information I have is the class name and the method name.
BreakpointManager.addMethodBreakpoint() requires a Document and lineIndex. I tried to use
session.process.virtualMachineProxy.virtualMachine.classesByName(className)
to look up the ReferenceType, which I could then use to call
methodsByName(methodName)
to get the Method object, and use that to find the file and line number. However, if I set this breakpoint right as the debug process is created, I can't guarantee that the class that I want to break on has been loaded yet, which means this lookup method won't work.
Are there any other ways to accomplish this?
Please sign in to leave a comment.
The class/method could be lookup using PSI. com.intellij.psi.JavaPsiFacade#findClass, then find PsiMethod and locate Document/linenumber as described here https://plugins.jetbrains.com/docs/intellij/documents.html#are-there-any-utilities-available-for-working-with-documents