[vala/wip/ricotz/lsp-rev: 11/13] vala: Add initial_argument_count to MA, OCE
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/ricotz/lsp-rev: 11/13] vala: Add initial_argument_count to MA, OCE
- Date: Wed, 5 Feb 2020 11:49:00 +0000 (UTC)
commit ee79ce298c5802b428dc6cc7c8bce02fc0551095
Author: Princeton Ferro <princetonferro gmail com>
Date: Sun Jan 26 04:23:25 2020 -0500
vala: Add initial_argument_count to MA, OCE
We use this to pass in information about the number of
initially-supplied arguments, since arguments may be filled
automatically later in semantic analysis. This is useful for language
servers implementing signature help.
vala/valamethodcall.vala | 9 ++++++++-
vala/valaobjectcreationexpression.vala | 9 ++++++++-
vala/valaparser.vala | 5 +++--
3 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index b9772fed8..150ad7874 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -52,16 +52,23 @@ public class Vala.MethodCall : Expression {
private List<Expression> argument_list = new ArrayList<Expression> ();
+ /**
+ * The number of arguments supplied before semantic analysis. For language servers.
+ */
+ public int initial_argument_count { get; private set; }
+
/**
* Creates a new invocation expression.
*
* @param call method to call
* @param source_reference reference to source code
+ * @param init_args initial count of arguments
* @return newly created invocation expression
*/
- public MethodCall (Expression call, SourceReference? source_reference = null) {
+ public MethodCall (Expression call, SourceReference? source_reference = null, int init_args = 0) {
this.source_reference = source_reference;
this.call = call;
+ this.initial_argument_count = init_args;
}
/**
diff --git a/vala/valaobjectcreationexpression.vala b/vala/valaobjectcreationexpression.vala
index 575d50b37..201f5568d 100644
--- a/vala/valaobjectcreationexpression.vala
+++ b/vala/valaobjectcreationexpression.vala
@@ -62,16 +62,23 @@ public class Vala.ObjectCreationExpression : Expression {
private DataType _data_type;
private MemberAccess? _member_name;
+ /**
+ * The number of arguments supplied before semantic analysis. For language servers.
+ */
+ public int initial_argument_count { get; private set; }
+
/**
* Creates a new object creation expression.
*
* @param member_name object type to create
* @param source_reference reference to source code
+ * @param init_args initial count of arguments
* @return newly created object creation expression
*/
- public ObjectCreationExpression (MemberAccess? member_name, SourceReference? source_reference = null)
{
+ public ObjectCreationExpression (MemberAccess? member_name, SourceReference? source_reference = null,
int init_args = 0) {
this.source_reference = source_reference;
this.member_name = member_name;
+ this.initial_argument_count = init_args;
}
/**
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 5bcdc23aa..4a6149f7e 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -597,6 +597,7 @@ public class Vala.Parser : CodeVisitor {
try {
list.add (parse_argument ());
} catch (ParseError e) {
+ list.add (new InvalidExpression ());
if (current () == TokenType.CLOSE_PARENS) {
prev ();
report_parse_error (new ParseError.SYNTAX ("incomplete
argument list"));
@@ -824,7 +825,7 @@ public class Vala.Parser : CodeVisitor {
unowned MemberAccess member = (MemberAccess) inner;
member.creation_member = true;
- var expr = new ObjectCreationExpression (member, src);
+ var expr = new ObjectCreationExpression (member, src, arg_list.size);
expr.struct_creation = true;
foreach (Expression arg in arg_list) {
expr.add_argument (arg);
@@ -834,7 +835,7 @@ public class Vala.Parser : CodeVisitor {
}
return expr;
} else {
- var expr = new MethodCall (inner, src);
+ var expr = new MethodCall (inner, src, arg_list.size);
foreach (Expression arg in arg_list) {
expr.add_argument (arg);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]