1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Support REPL expressions through DAP evaluate request

This commit is contained in:
Ricardo Subtil
2024-09-30 14:15:09 +01:00
parent 6aac039ee7
commit 0d098d3cca
6 changed files with 71 additions and 11 deletions

View File

@@ -799,6 +799,22 @@ void DebugAdapterProtocol::parse_object(SceneDebuggerObject &p_obj) {
variable_list.insert(object_list[object_id], properties);
}
void DebugAdapterProtocol::parse_evaluation(DebuggerMarshalls::ScriptStackVariable &p_var) {
// If the eval is not on the pending list, we weren't expecting it. Ignore it.
String eval = p_var.name;
if (!eval_pending_list.erase(eval)) {
return;
}
DAP::Variable variable;
variable.name = p_var.name;
variable.value = p_var.value;
variable.type = Variant::get_type_name(p_var.value.get_type());
variable.variablesReference = parse_variant(p_var.value);
eval_list.insert(variable.name, variable);
}
const Variant DebugAdapterProtocol::parse_object_variable(const SceneDebuggerObject::SceneDebuggerProperty &p_property) {
const PropertyInfo &info = p_property.first;
const Variant &value = p_property.second;
@@ -833,6 +849,18 @@ bool DebugAdapterProtocol::request_remote_object(const ObjectID &p_object_id) {
return true;
}
bool DebugAdapterProtocol::request_remote_evaluate(const String &p_eval, int p_stack_frame) {
// If the eval is already on the pending list, we don't need to request it again
if (eval_pending_list.has(p_eval)) {
return false;
}
EditorDebuggerNode::get_singleton()->get_default_debugger()->request_remote_evaluate(p_eval, p_stack_frame);
eval_pending_list.insert(p_eval);
return true;
}
bool DebugAdapterProtocol::process_message(const String &p_text) {
JSON json;
ERR_FAIL_COND_V_MSG(json.parse(p_text) != OK, true, "Malformed message!");
@@ -1148,6 +1176,12 @@ void DebugAdapterProtocol::on_debug_data(const String &p_msg, const Array &p_dat
remote_obj.deserialize(p_data);
parse_object(remote_obj);
} else if (p_msg == "evaluation_return") {
// An evaluation was requested from the debuggee; parse it.
DebuggerMarshalls::ScriptStackVariable remote_evaluation;
remote_evaluation.deserialize(p_data);
parse_evaluation(remote_evaluation);
}
notify_custom_data(p_msg, p_data);