[vala/wip/ricotz/lsp: 2/13] langserver: don't advance token after parse error



commit d72e0f0842635bb1e8639dc09f458b04b6d146e3
Author: Princeton Ferro <princetonferro gmail com>
Date:   Thu Jan 9 09:39:52 2020 -0500

    langserver: don't advance token after parse error

 vala/valaparser.vala | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 2fed8c2f8..bc54dc80a 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -115,9 +115,11 @@ public class Vala.Parser : CodeVisitor {
                return false;
        }
 
-       void report_parse_error (ParseError e) {
+       void report_parse_error (ParseError e, bool advance = true) {
                var begin = get_location ();
-               next ();
+               if (advance) {
+                       next ();
+               }
                Report.error (get_src (begin), "syntax error, " + e.message);
        }
 
@@ -750,7 +752,7 @@ public class Vala.Parser : CodeVisitor {
                        id = parse_identifier ();
                } catch (ParseError e) {
                        if (context.keep_going) {
-                               report_parse_error (e);
+                               report_parse_error (e, false);
                        } else {
                                throw e;
                        }
@@ -772,7 +774,7 @@ public class Vala.Parser : CodeVisitor {
                        id = parse_identifier ();
                } catch (ParseError e) {
                        if (context.keep_going) {
-                               report_parse_error (e);
+                               report_parse_error (e, false);
                        } else {
                                throw e;
                        }
@@ -1928,7 +1930,7 @@ public class Vala.Parser : CodeVisitor {
                var src = get_src (begin);
                if (context.keep_going) {
                        if (!accept (TokenType.SEMICOLON)) {
-                               report_parse_error (new ParseError.SYNTAX ("expected %s".printf 
(TokenType.SEMICOLON.to_string ())));
+                               report_parse_error (new ParseError.SYNTAX ("expected %s".printf 
(TokenType.SEMICOLON.to_string ())), false);
                        }
                } else {
                        expect (TokenType.SEMICOLON);


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