Browse Source

Add output type to DAP `output` events

Ricardo Subtil 1 year ago
parent
commit
b6d1204186

+ 2 - 2
editor/debugger/debug_adapter/debug_adapter_parser.cpp

@@ -600,12 +600,12 @@ Dictionary DebugAdapterParser::ev_continued() const {
 	return event;
 	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;
 	Dictionary event = prepare_base_event(), body;
 	event["event"] = "output";
 	event["event"] = "output";
 	event["body"] = body;
 	event["body"] = body;
 
 
-	body["category"] = "stdout";
+	body["category"] = (p_type == RemoteDebugger::MessageType::MESSAGE_TYPE_ERROR) ? "stderr" : "stdout";
 	body["output"] = p_message + "\r\n";
 	body["output"] = p_message + "\r\n";
 
 
 	return event;
 	return event;

+ 2 - 1
editor/debugger/debug_adapter/debug_adapter_parser.h

@@ -32,6 +32,7 @@
 #define DEBUG_ADAPTER_PARSER_H
 #define DEBUG_ADAPTER_PARSER_H
 
 
 #include "core/config/project_settings.h"
 #include "core/config/project_settings.h"
+#include "core/debugger/remote_debugger.h"
 #include "debug_adapter_protocol.h"
 #include "debug_adapter_protocol.h"
 #include "debug_adapter_types.h"
 #include "debug_adapter_types.h"
 
 
@@ -98,7 +99,7 @@ public:
 	Dictionary ev_stopped_breakpoint(const int &p_id) const;
 	Dictionary ev_stopped_breakpoint(const int &p_id) const;
 	Dictionary ev_stopped_step() const;
 	Dictionary ev_stopped_step() const;
 	Dictionary ev_continued() 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_custom_data(const String &p_msg, const Array &p_data) const;
 	Dictionary ev_breakpoint(const DAP::Breakpoint &p_breakpoint, const bool &p_enabled) const;
 	Dictionary ev_breakpoint(const DAP::Breakpoint &p_breakpoint, const bool &p_enabled) const;
 };
 };

+ 4 - 4
editor/debugger/debug_adapter/debug_adapter_protocol.cpp

@@ -763,8 +763,8 @@ void DebugAdapterProtocol::notify_continued() {
 	reset_stack_info();
 	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()) {
 	for (List<Ref<DAPeer>>::Element *E = clients.front(); E; E = E->next()) {
 		E->get()->res_queue.push_back(event);
 		E->get()->res_queue.push_back(event);
 	}
 	}
@@ -828,8 +828,8 @@ void DebugAdapterProtocol::on_debug_stopped() {
 	notify_terminated();
 	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) {
 void DebugAdapterProtocol::on_debug_breaked(const bool &p_reallydid, const bool &p_can_debug, const String &p_reason, const bool &p_has_stackdump) {

+ 2 - 2
editor/debugger/debug_adapter/debug_adapter_protocol.h

@@ -86,7 +86,7 @@ private:
 	void on_client_disconnected(const Ref<DAPeer> &p_peer);
 	void on_client_disconnected(const Ref<DAPeer> &p_peer);
 	void on_debug_paused();
 	void on_debug_paused();
 	void on_debug_stopped();
 	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_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_breakpoint_toggled(const String &p_path, const int &p_line, const bool &p_enabled);
 	void on_debug_stack_dump(const Array &p_stack_dump);
 	void on_debug_stack_dump(const Array &p_stack_dump);
@@ -139,7 +139,7 @@ public:
 	void notify_stopped_breakpoint(const int &p_id);
 	void notify_stopped_breakpoint(const int &p_id);
 	void notify_stopped_step();
 	void notify_stopped_step();
 	void notify_continued();
 	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_custom_data(const String &p_msg, const Array &p_data);
 	void notify_breakpoint(const DAP::Breakpoint &p_breakpoint, const bool &p_enabled);
 	void notify_breakpoint(const DAP::Breakpoint &p_breakpoint, const bool &p_enabled);
 
 

+ 2 - 2
editor/debugger/script_editor_debugger.cpp

@@ -495,7 +495,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, uint64_t p_thread
 				} break;
 				} break;
 			}
 			}
 			EditorNode::get_log()->add_message(output_strings[i], msg_type);
 			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") {
 	} else if (p_msg == "performance:profile_frame") {
 		Vector<float> frame_data;
 		Vector<float> frame_data;
@@ -1757,7 +1757,7 @@ void ScriptEditorDebugger::_bind_methods() {
 	ADD_SIGNAL(MethodInfo("remote_object_updated", PropertyInfo(Variant::INT, "id")));
 	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_object_property_updated", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::STRING, "property")));
 	ADD_SIGNAL(MethodInfo("remote_tree_updated"));
 	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_dump", PropertyInfo(Variant::ARRAY, "stack_dump")));
 	ADD_SIGNAL(MethodInfo("stack_frame_vars", PropertyInfo(Variant::INT, "num_vars")));
 	ADD_SIGNAL(MethodInfo("stack_frame_vars", PropertyInfo(Variant::INT, "num_vars")));
 	ADD_SIGNAL(MethodInfo("stack_frame_var", PropertyInfo(Variant::ARRAY, "data")));
 	ADD_SIGNAL(MethodInfo("stack_frame_var", PropertyInfo(Variant::ARRAY, "data")));