Skip to content

Commit

Permalink
Add output type to DAP output events
Browse files Browse the repository at this point in the history
  • Loading branch information
rsubtil committed Mar 14, 2024
1 parent f2045ba commit b6d1204
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions editor/debugger/debug_adapter/debug_adapter_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,12 +600,12 @@ Dictionary DebugAdapterParser::ev_continued() const {
return event;
}

Dictionary DebugAdapterParser::ev_output(const String &p_message) const {
Dictionary DebugAdapterParser::ev_output(const String &p_message, RemoteDebugger::MessageType p_type) const {
Dictionary event = prepare_base_event(), body;
event["event"] = "output";
event["body"] = body;

body["category"] = "stdout";
body["category"] = (p_type == RemoteDebugger::MessageType::MESSAGE_TYPE_ERROR) ? "stderr" : "stdout";
body["output"] = p_message + "\r\n";

return event;
Expand Down
3 changes: 2 additions & 1 deletion editor/debugger/debug_adapter/debug_adapter_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#define DEBUG_ADAPTER_PARSER_H

#include "core/config/project_settings.h"
#include "core/debugger/remote_debugger.h"
#include "debug_adapter_protocol.h"
#include "debug_adapter_types.h"

Expand Down Expand Up @@ -98,7 +99,7 @@ class DebugAdapterParser : public Object {
Dictionary ev_stopped_breakpoint(const int &p_id) const;
Dictionary ev_stopped_step() const;
Dictionary ev_continued() const;
Dictionary ev_output(const String &p_message) const;
Dictionary ev_output(const String &p_message, RemoteDebugger::MessageType p_type) const;
Dictionary ev_custom_data(const String &p_msg, const Array &p_data) const;
Dictionary ev_breakpoint(const DAP::Breakpoint &p_breakpoint, const bool &p_enabled) const;
};
Expand Down
8 changes: 4 additions & 4 deletions editor/debugger/debug_adapter/debug_adapter_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -763,8 +763,8 @@ void DebugAdapterProtocol::notify_continued() {
reset_stack_info();
}

void DebugAdapterProtocol::notify_output(const String &p_message) {
Dictionary event = parser->ev_output(p_message);
void DebugAdapterProtocol::notify_output(const String &p_message, RemoteDebugger::MessageType p_type) {
Dictionary event = parser->ev_output(p_message, p_type);
for (List<Ref<DAPeer>>::Element *E = clients.front(); E; E = E->next()) {
E->get()->res_queue.push_back(event);
}
Expand Down Expand Up @@ -828,8 +828,8 @@ void DebugAdapterProtocol::on_debug_stopped() {
notify_terminated();
}

void DebugAdapterProtocol::on_debug_output(const String &p_message) {
notify_output(p_message);
void DebugAdapterProtocol::on_debug_output(const String &p_message, int p_type) {
notify_output(p_message, RemoteDebugger::MessageType(p_type));
}

void DebugAdapterProtocol::on_debug_breaked(const bool &p_reallydid, const bool &p_can_debug, const String &p_reason, const bool &p_has_stackdump) {
Expand Down
4 changes: 2 additions & 2 deletions editor/debugger/debug_adapter/debug_adapter_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class DebugAdapterProtocol : public Object {
void on_client_disconnected(const Ref<DAPeer> &p_peer);
void on_debug_paused();
void on_debug_stopped();
void on_debug_output(const String &p_message);
void on_debug_output(const String &p_message, int p_type);
void on_debug_breaked(const bool &p_reallydid, const bool &p_can_debug, const String &p_reason, const bool &p_has_stackdump);
void on_debug_breakpoint_toggled(const String &p_path, const int &p_line, const bool &p_enabled);
void on_debug_stack_dump(const Array &p_stack_dump);
Expand Down Expand Up @@ -139,7 +139,7 @@ class DebugAdapterProtocol : public Object {
void notify_stopped_breakpoint(const int &p_id);
void notify_stopped_step();
void notify_continued();
void notify_output(const String &p_message);
void notify_output(const String &p_message, RemoteDebugger::MessageType p_type);
void notify_custom_data(const String &p_msg, const Array &p_data);
void notify_breakpoint(const DAP::Breakpoint &p_breakpoint, const bool &p_enabled);

Expand Down
4 changes: 2 additions & 2 deletions editor/debugger/script_editor_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, uint64_t p_thread
} break;
}
EditorNode::get_log()->add_message(output_strings[i], msg_type);
emit_signal(SNAME("output"), output_strings[i]);
emit_signal(SNAME("output"), output_strings[i], msg_type);
}
} else if (p_msg == "performance:profile_frame") {
Vector<float> frame_data;
Expand Down Expand Up @@ -1757,7 +1757,7 @@ void ScriptEditorDebugger::_bind_methods() {
ADD_SIGNAL(MethodInfo("remote_object_updated", PropertyInfo(Variant::INT, "id")));
ADD_SIGNAL(MethodInfo("remote_object_property_updated", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::STRING, "property")));
ADD_SIGNAL(MethodInfo("remote_tree_updated"));
ADD_SIGNAL(MethodInfo("output"));
ADD_SIGNAL(MethodInfo("output", PropertyInfo(Variant::STRING, "msg"), PropertyInfo(Variant::INT, "level")));
ADD_SIGNAL(MethodInfo("stack_dump", PropertyInfo(Variant::ARRAY, "stack_dump")));
ADD_SIGNAL(MethodInfo("stack_frame_vars", PropertyInfo(Variant::INT, "num_vars")));
ADD_SIGNAL(MethodInfo("stack_frame_var", PropertyInfo(Variant::ARRAY, "data")));
Expand Down

0 comments on commit b6d1204

Please sign in to comment.