I am developing a plugin that needs to analyze the local variables of the current stack frame when the debugger suspends. I have been able to use com.intellij.debugger.engine.JavaStackFrame#computeChildren
to receive the values in an implementation of com.intellij.xdebugger.frame.XCompositeNode
, cast those values to com.intellij.debugger.engine.JavaValue
and get their descriptors.
The issue I am having is that on the first suspend, com.intellij.debugger.ui.tree.ValueDescriptor#getType()
and com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl#getValue()
both return null for all values in the frame. On subsequent suspends for further lines of the same class/method, these methods will start returning values. I have also noticed that if I click off the paused frame to a prior one, then click back to the original frame the types/values will be present then as well.
It seems that there is something I need to do to force a lazy evaluation, or an asynchronous operation I need to wait for? I have tried also using com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl#getFullValueDescriptor
and com.intellij.xdebugger.evaluation.XInstanceEvaluator#evaluate
thinking these might trigger a more thorough evaluation but I get the same result.
An excerpt of the relevant code is below. Thanks in advance for any advice.
@Override
public void addChildren(@NotNull XValueChildrenList xValueChildrenList, boolean b) {
for (int i = 0; i < xValueChildrenList.size(); i++) {
String name = xValueChildrenList.getName(i);
JavaValue value = (JavaValue) xValueChildrenList.getValue(i);
//these are both null on the first suspend
var type = value.getDescriptor().getType();
var descriptorValue = value.getDescriptor().getValue();
}
}
Using IDEA 2024.3.5
I am unable to link to my plugin source as it is for internal use. Hopefully this question has a simple answer - if not I can try to recreate just the debugger issues in an isolated public project.