[vala/wip/ricotz/lsp: 7/7] vala: Extent InvalidExpression
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/ricotz/lsp: 7/7] vala: Extent InvalidExpression
- Date: Fri, 10 Jan 2020 13:53:50 +0000 (UTC)
commit 7a42d418a3929e15510395e644e8e4dbc37290f7
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Fri Jan 10 14:52:49 2020 +0100
vala: Extent InvalidExpression
vala/valainvalidexpression.vala | 11 ++++++++++-
vala/valaobjectcreationexpression.vala | 20 --------------------
vala/valaparser.vala | 5 +++--
3 files changed, 13 insertions(+), 23 deletions(-)
---
diff --git a/vala/valainvalidexpression.vala b/vala/valainvalidexpression.vala
index cf4dca742..11bc2d0ac 100644
--- a/vala/valainvalidexpression.vala
+++ b/vala/valainvalidexpression.vala
@@ -26,7 +26,9 @@ using GLib;
* An invalid expression.
*/
public class Vala.InvalidExpression : Expression {
- public InvalidExpression () {
+ public InvalidExpressionType kind { get; private set; }
+
+ public InvalidExpression (InvalidExpressionType kind = InvalidExpressionType.NONE, SourceReference?
source_reference = null) {
error = true;
}
@@ -34,3 +36,10 @@ public class Vala.InvalidExpression : Expression {
return false;
}
}
+
+public enum Vala.InvalidExpressionType {
+ NONE,
+ ARGUMENT,
+ EMPTY,
+ INCOMPLETE
+}
diff --git a/vala/valaobjectcreationexpression.vala b/vala/valaobjectcreationexpression.vala
index a65633016..575d50b37 100644
--- a/vala/valaobjectcreationexpression.vala
+++ b/vala/valaobjectcreationexpression.vala
@@ -55,11 +55,6 @@ public class Vala.ObjectCreationExpression : Expression {
public bool struct_creation { get; set; }
- /**
- * For language servers, whether the object creation expression is incomplete.
- */
- public bool is_incomplete { get; private set; }
-
private List<Expression> argument_list = new ArrayList<Expression> ();
private List<MemberInitializer> object_initializer = new ArrayList<MemberInitializer> ();
@@ -79,21 +74,6 @@ public class Vala.ObjectCreationExpression : Expression {
this.member_name = member_name;
}
- /**
- * Creates a new incomplete object creation expression, such as
- * `new ...'
- *
- * @param member_name object type to create
- * @param source_reference reference to source code
- * @return newly created object creation expression
- */
- public ObjectCreationExpression.incomplete (MemberAccess? member_name, SourceReference?
source_reference = null) {
- this.source_reference = source_reference;
- this.member_name = member_name;
- this.is_incomplete = true;
- error = true;
- }
-
/**
* Appends the specified expression to the list of arguments.
*
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 2fb3f2c9f..4e98d9b40 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -567,11 +567,12 @@ public class Vala.Parser : CodeVisitor {
var list = new ArrayList<Expression> ();
if (current () != TokenType.CLOSE_PARENS) {
do {
+ var begin = get_location ();
try {
list.add (parse_argument ());
} catch (ParseError e) {
if (context.keep_going) {
- list.add (new InvalidExpression ());
+ list.add (new InvalidExpression
(InvalidExpressionType.ARGUMENT, get_src (begin)));
report_parse_error (e, false);
// exit this loop, since language server uses
// number of correctly-supplied arguments from
@@ -926,7 +927,7 @@ public class Vala.Parser : CodeVisitor {
var expr = parse_array_creation_expression ();
return expr;
} else if (context.keep_going) {
- var expr = new ObjectCreationExpression.incomplete (member, get_src (begin));
+ var expr = new InvalidExpression (InvalidExpressionType.INCOMPLETE, get_src
(begin));
return expr;
} else {
throw new ParseError.SYNTAX ("expected ( or [");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]