[vala/wip/ricotz/lsp: 3/4] parser: Use InvalidExpression for empty arguments



commit 54db49ec753950ac30e9e03d4ff7cb31b9f6d4cd
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Jan 9 18:40:42 2020 +0100

    parser: Use InvalidExpression for empty arguments

 vala/valainvalidexpression.vala        |  4 ++++
 vala/valamethodcall.vala               | 10 ----------
 vala/valaobjectcreationexpression.vala | 10 ----------
 vala/valaparser.vala                   | 15 ++++-----------
 4 files changed, 8 insertions(+), 31 deletions(-)
---
diff --git a/vala/valainvalidexpression.vala b/vala/valainvalidexpression.vala
index 89341673b..cf4dca742 100644
--- a/vala/valainvalidexpression.vala
+++ b/vala/valainvalidexpression.vala
@@ -29,4 +29,8 @@ public class Vala.InvalidExpression : Expression {
        public InvalidExpression () {
                error = true;
        }
+
+       public override bool is_pure () {
+               return false;
+       }
 }
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index 98ad23962..06d20aa79 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -48,16 +48,6 @@ public class Vala.MethodCall : Expression {
 
        public bool is_chainup { get; private set; }
 
-       /**
-        * For language servers, the number of completed arguments from the left.
-        */
-       public int initial_argument_count { get; set; }
-
-       /**
-        * For language servers, whether there is an extra comma at the end of the argument list.
-        */
-       public bool extra_comma { get; set; }
-
        private Expression _call;
 
        private List<Expression> argument_list = new ArrayList<Expression> ();
diff --git a/vala/valaobjectcreationexpression.vala b/vala/valaobjectcreationexpression.vala
index ef9f288f6..f68e2603e 100644
--- a/vala/valaobjectcreationexpression.vala
+++ b/vala/valaobjectcreationexpression.vala
@@ -55,16 +55,6 @@ public class Vala.ObjectCreationExpression : Expression {
 
        public bool struct_creation { get; set; }
 
-       /**
-        * For language servers, the number of completed arguments from the left.
-        */
-       public int initial_argument_count { get; set; }
-
-       /**
-        * For language servers, whether there is an extra comma at the end of the argument list.
-        */
-       public bool extra_comma { get; set; }
-
        /**
         * For language servers, whether the object creation expression is incomplete.
         */
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 95b9fece0..2fb3f2c9f 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -563,16 +563,15 @@ public class Vala.Parser : CodeVisitor {
                return type;
        }
 
-       List<Expression> parse_argument_list (out bool extra_comma) throws ParseError {
+       List<Expression> parse_argument_list () throws ParseError {
                var list = new ArrayList<Expression> ();
-               extra_comma = false;
                if (current () != TokenType.CLOSE_PARENS) {
                        do {
                                try {
                                        list.add (parse_argument ());
                                } catch (ParseError e) {
                                        if (context.keep_going) {
-                                               extra_comma = true;
+                                               list.add (new InvalidExpression ());
                                                report_parse_error (e, false);
                                                // exit this loop, since language server uses
                                                // number of correctly-supplied arguments from
@@ -805,8 +804,7 @@ public class Vala.Parser : CodeVisitor {
 
        Expression parse_method_call (SourceLocation begin, Expression inner) throws ParseError {
                expect (TokenType.OPEN_PARENS);
-               bool extra_comma;
-               var arg_list = parse_argument_list (out extra_comma);
+               var arg_list = parse_argument_list ();
                if (context.keep_going) {
                        if (!accept (TokenType.CLOSE_PARENS)) {
                                report_parse_error (new ParseError.SYNTAX ("expected %s".printf 
(TokenType.CLOSE_PARENS.to_string ())), false);
@@ -837,8 +835,6 @@ public class Vala.Parser : CodeVisitor {
                        foreach (Expression arg in arg_list) {
                                expr.add_argument (arg);
                        }
-                       expr.initial_argument_count = arg_list.size;
-                       expr.extra_comma = extra_comma;
                        return expr;
                }
        }
@@ -940,8 +936,7 @@ public class Vala.Parser : CodeVisitor {
 
        Expression parse_object_creation_expression (SourceLocation begin, MemberAccess member) throws 
ParseError {
                member.creation_member = true;
-               bool extra_comma;
-               var arg_list = parse_argument_list (out extra_comma);
+               var arg_list = parse_argument_list ();
                if (context.keep_going) {
                        if (!accept (TokenType.CLOSE_PARENS)) {
                                report_parse_error (new ParseError.SYNTAX ("expected %s", 
TokenType.CLOSE_PARENS.to_string ()), false);
@@ -957,11 +952,9 @@ public class Vala.Parser : CodeVisitor {
                foreach (Expression arg in arg_list) {
                        expr.add_argument (arg);
                }
-               expr.initial_argument_count = arg_list.size;
                foreach (MemberInitializer initializer in init_list) {
                        expr.add_member_initializer (initializer);
                }
-               expr.extra_comma = extra_comma;
                return expr;
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]