[vala/wip/ricotz/lsp-rev: 13/13] parser: Use init_args = -1 for incomplete OCEs



commit 331f97c053447e13ff1f09bbfbc418b847a987ba
Author: Princeton Ferro <princetonferro gmail com>
Date:   Sun Jan 26 07:38:34 2020 -0500

    parser: Use init_args = -1 for incomplete OCEs
    
    When in keep-going mode, we handle incomplete OCEs (OCEs without an
    argument list) and set initial_argument_count = -1. This allows language
    servers to distinguish from normal OCEs and provide member access
    completions. For example:
    
    new Vala. <-- server can now show list of types
    new Gdk.Pixbuf. <-- server can show list of constructors

 vala/valaparser.vala | 4 ++++
 1 file changed, 4 insertions(+)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 4a6149f7e..e948c5949 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -919,6 +919,10 @@ public class Vala.Parser : CodeVisitor {
                                rollback (begin);
                                var expr = parse_array_creation_expression ();
                                return expr;
+                       } else if (context.keep_going) {
+                               // -1 represents that there isn't even an argument list
+                               var expr = new ObjectCreationExpression (member, get_src (begin), -1);
+                               return expr;
                        } else {
                                throw new ParseError.SYNTAX ("expected ( or [");
                        }


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