[vala/staging] vala: Add ObjectCreationExpression.to_string()
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] vala: Add ObjectCreationExpression.to_string()
- Date: Thu, 20 Aug 2020 10:18:33 +0000 (UTC)
commit 4424e8328d327c23f87515b01b918f661aafaf27
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Aug 19 17:42:37 2020 +0200
vala: Add ObjectCreationExpression.to_string()
vala/valamethodcall.vala | 3 +--
vala/valaobjectcreationexpression.vala | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+), 2 deletions(-)
---
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;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]