From: Rico Tzschichholz Date: Wed, 19 Aug 2020 15:42:37 +0000 (+0200) Subject: vala: Add ObjectCreationExpression.to_string() X-Git-Tag: 0.49.91~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4424e8328d327c23f87515b01b918f661aafaf27;p=thirdparty%2Fvala.git vala: Add ObjectCreationExpression.to_string() --- diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala index d7b58ac85..ab98f99bd 100644 --- a/vala/valamethodcall.vala +++ b/vala/valamethodcall.vala @@ -746,7 +746,6 @@ public class Vala.MethodCall : Expression { public override string to_string () { var b = new StringBuilder (); - b.append_c ('('); if (is_yield_expression) { b.append ("yield "); } @@ -761,7 +760,7 @@ public class Vala.MethodCall : Expression { b.append (expr.to_string ()); first = false; } - b.append ("))"); + b.append_c (')'); return b.str; } diff --git a/vala/valaobjectcreationexpression.vala b/vala/valaobjectcreationexpression.vala index b01431c4e..9c7f6133c 100644 --- a/vala/valaobjectcreationexpression.vala +++ b/vala/valaobjectcreationexpression.vala @@ -576,4 +576,30 @@ public class Vala.ObjectCreationExpression : Expression { init.get_used_variables (collection); } } + + public override string to_string () { + var b = new StringBuilder (); + if (is_yield_expression) { + b.append ("yield "); + } + if (!struct_creation) { + b.append ("new "); + } + if (member_name != null) { + b.append (member_name.to_string ()); + } + b.append_c ('('); + + bool first = true; + foreach (var expr in argument_list) { + if (!first) { + b.append (", "); + } + b.append (expr.to_string ()); + first = false; + } + b.append_c (')'); + + return b.str; + } }