]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Improve Symbol.to_string() to include TypeParameters
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 8 Apr 2023 13:50:53 +0000 (15:50 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 8 Apr 2023 13:50:53 +0000 (15:50 +0200)
vala/valasymbol.vala

index 7e8b4493a450cb5c8efe64a6a0e9de5aebebcd57..ebee414ec399b745c25ec517230512b7a5419615 100644 (file)
@@ -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<TypeParameter>? 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;
        }
 }