diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2023-04-08 15:50:53 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2023-04-08 15:50:53 +0200 |
commit | 64799db98cde757b73430271cc179bb1838f1ed7 (patch) | |
tree | 76593700cbb773a8d7f5d6cbb4ff9c0f8f9928e8 /vala/valasymbol.vala | |
parent | 84b531ab37e271895f751279c1bbc51b6f2ac393 (diff) | |
download | vala-64799db98cde757b73430271cc179bb1838f1ed7.tar.gz |
vala: Improve Symbol.to_string() to include TypeParameters
Diffstat (limited to 'vala/valasymbol.vala')
-rw-r--r-- | vala/valasymbol.vala | 28 |
1 files changed, 27 insertions, 1 deletions
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<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; } } |