From 64799db98cde757b73430271cc179bb1838f1ed7 Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Sat, 8 Apr 2023 15:50:53 +0200 Subject: vala: Improve Symbol.to_string() to include TypeParameters --- vala/valasymbol.vala | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/vala/valasymbol.vala b/vala/valasymbol.vala index 7e8b4493a..ebee414ec 100644 --- a/vala/valasymbol.vala +++ b/vala/valasymbol.vala @@ -508,7 +508,33 @@ public abstract class Vala.Symbol : CodeNode { } public override string to_string () { - return get_full_name (); + var builder = new StringBuilder (get_full_name ()); + + unowned List? type_params = null; + if (this is Delegate) { + type_params = ((Delegate) this).get_type_parameters (); + } else if (this is Method) { + type_params = ((Method) this).get_type_parameters (); + } else if (this is ObjectTypeSymbol) { + type_params = ((ObjectTypeSymbol) this).get_type_parameters (); + } else if (this is Struct) { + type_params = ((Struct) this).get_type_parameters (); + } + if (type_params != null && type_params.size > 0) { + builder.append_c ('<'); + bool first = true; + foreach (var type_param in type_params) { + if (!first) { + builder.append_c (','); + } else { + first = false; + } + builder.append (type_param.name); + } + builder.append_c ('>'); + } + + return builder.str; } } -- cgit v1.2.1