[vala/0.40] parser: Improve source-location for LocalVariable/DeclarationStatement
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.40] parser: Improve source-location for LocalVariable/DeclarationStatement
- Date: Mon, 5 Aug 2019 11:37:10 +0000 (UTC)
commit 60036e2679b56f0a17f8848b70cb8ae77d3b97d5
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Apr 10 14:12:21 2019 +0200
parser: Improve source-location for LocalVariable/DeclarationStatement
vala/valaparser.vala | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 382df65a7..3e92f5502 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -1793,16 +1793,18 @@ public class Vala.Parser : CodeVisitor {
}
void parse_local_variable_declarations (Block block) throws ParseError {
+ var begin = get_location ();
DataType variable_type;
if (accept (TokenType.VAR)) {
variable_type = null;
} else {
variable_type = parse_type (true, true);
}
+ bool is_first = true;
do {
if (variable_type == null && accept (TokenType.OPEN_PARENS)) {
// tuple
- var begin = get_location ();
+ begin = get_location ();
string[] identifiers = {};
do {
@@ -1826,12 +1828,18 @@ public class Vala.Parser : CodeVisitor {
continue;
}
+ if (!is_first) {
+ begin = get_location ();
+ } else {
+ is_first = false;
+ }
+
DataType type_copy = null;
if (variable_type != null) {
type_copy = variable_type.copy ();
}
var local = parse_local_variable (type_copy);
- block.add_statement (new DeclarationStatement (local, local.source_reference));
+ block.add_statement (new DeclarationStatement (local, get_src (begin)));
} while (accept (TokenType.COMMA));
expect (TokenType.SEMICOLON);
}
@@ -1839,14 +1847,14 @@ public class Vala.Parser : CodeVisitor {
LocalVariable parse_local_variable (DataType? variable_type) throws ParseError {
var begin = get_location ();
string id = parse_identifier ();
-
var type = parse_inline_array_type (variable_type);
+ var src = get_src (begin);
Expression initializer = null;
if (accept (TokenType.ASSIGN)) {
initializer = parse_expression ();
}
- return new LocalVariable (type, id, initializer, get_src (begin));
+ return new LocalVariable (type, id, initializer, src);
}
void parse_local_constant_declarations (Block block) throws ParseError {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]