Add expression evaluater to debugger (REPL)

Co-authored-by: rohanrhu <rohanrhu2@gmail.com>
This commit is contained in:
kobewi 2024-09-30 17:48:27 +02:00
parent e3213aaef5
commit 645abdbb80
8 changed files with 291 additions and 6 deletions

View file

@ -37,6 +37,7 @@
#include "core/string/ustring.h"
#include "core/version.h"
#include "editor/debugger/debug_adapter/debug_adapter_protocol.h"
#include "editor/debugger/editor_expression_evaluator.h"
#include "editor/debugger/editor_performance_profiler.h"
#include "editor/debugger/editor_profiler.h"
#include "editor/debugger/editor_visual_profiler.h"
@ -811,6 +812,8 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, uint64_t p_thread
if (EditorFileSystem::get_singleton()) {
EditorFileSystem::get_singleton()->update_file(p_data[0]);
}
} else if (p_msg == "evaluation_return") {
expression_evaluator->add_value(p_data);
} else {
int colon_index = p_msg.find_char(':');
ERR_FAIL_COND_MSG(colon_index < 1, "Invalid message received");
@ -854,8 +857,9 @@ void ScriptEditorDebugger::_notification(int p_what) {
error_tree->connect(SceneStringName(item_selected), callable_mp(this, &ScriptEditorDebugger::_error_selected));
error_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_error_activated));
breakpoints_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_breakpoint_tree_clicked));
[[fallthrough]];
}
connect("started", callable_mp(expression_evaluator, &EditorExpressionEvaluator::on_start));
} break;
case NOTIFICATION_THEME_CHANGED: {
tabs->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("DebuggerPanel"), EditorStringName(EditorStyles)));
@ -2010,6 +2014,13 @@ ScriptEditorDebugger::ScriptEditorDebugger() {
add_child(file_dialog);
}
{ // Expression evaluator
expression_evaluator = memnew(EditorExpressionEvaluator);
expression_evaluator->set_name(TTR("Evaluator"));
expression_evaluator->set_editor_debugger(this);
tabs->add_child(expression_evaluator);
}
{ //profiler
profiler = memnew(EditorProfiler);
profiler->set_name(TTR("Profiler"));