How to get the type and value of a debugging variable (XValue)?

Answered

I am trying to visualize the variables during the debugging process in IntelliJ. Coming from this post: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360010503200-Accessing-the-debug-information-variables-while-debugging-with-a-plugin-Intellij-

I know that I can continuously call computeChildren() to navigate deeper and deeper in the debugging tree. However, I am not yet able to read the information I am interested in from the XValue objects.

I am looking for the type and value of the variable which seems to be hidden inside the myValueDescriptor field. But I do not know how to get it and I cannot cast the variable to JavaValue because I have no dependency on this class.

I have attached screenshots of the things I am trying to get, which can be found when debugging:

What is the cleanest way to get the information I need? Is there some kind of official API or method I am missing?

2 comments
Comment actions Permalink

You'll need to add dependency on Java plugin (https://blog.jetbrains.com/platform/2019/06/java-functionality-extracted-as-a-plugin/), then you can cast XValue and use com.intellij.debugger.ui.impl.watch.NodeDescriptorProvider#getDescriptor

1
Comment actions Permalink

Thanks a lot. It works perfectly for me!

0

Please sign in to leave a comment.