Support object inspection through DAP variables request

This commit is contained in:
Ricardo Subtil 2024-09-24 21:33:29 +01:00
parent 5ccbf6e4c7
commit 6aac039ee7
3 changed files with 192 additions and 10 deletions

View file

@ -442,26 +442,34 @@ Dictionary DebugAdapterParser::req_variables(const Dictionary &p_params) const {
return Dictionary();
}
Dictionary response = prepare_success_response(p_params), body;
response["body"] = body;
Dictionary args = p_params["arguments"];
int variable_id = args["variablesReference"];
HashMap<int, Array>::Iterator E = DebugAdapterProtocol::get_singleton()->variable_list.find(variable_id);
if (HashMap<int, Array>::Iterator E = DebugAdapterProtocol::get_singleton()->variable_list.find(variable_id); E) {
Dictionary response = prepare_success_response(p_params);
Dictionary body;
response["body"] = body;
if (E) {
if (!DebugAdapterProtocol::get_singleton()->get_current_peer()->supportsVariableType) {
for (int i = 0; i < E->value.size(); i++) {
Dictionary variable = E->value[i];
variable.erase("type");
}
}
body["variables"] = E ? E->value : Array();
return response;
} else {
return Dictionary();
// If the requested variable is an object, it needs to be requested from the debuggee.
ObjectID object_id = DebugAdapterProtocol::get_singleton()->search_object_id(variable_id);
if (object_id.is_null()) {
return prepare_error_response(p_params, DAP::ErrorType::UNKNOWN);
}
DebugAdapterProtocol::get_singleton()->request_remote_object(object_id);
}
return Dictionary();
}
Dictionary DebugAdapterParser::req_next(const Dictionary &p_params) const {