From: Rico Tzschichholz Date: Mon, 20 Jan 2020 11:45:03 +0000 (+0100) Subject: girparser: Improve source_reference of parameters X-Git-Tag: 0.47.3~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69ea76f8cb6d7863557e75b786530708c5d55b93;p=thirdparty%2Fvala.git girparser: Improve source_reference of parameters --- diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala index 17b41b1e5..f30d8b0d5 100644 --- a/vala/valagirparser.vala +++ b/vala/valagirparser.vala @@ -1453,6 +1453,14 @@ public class Vala.GirParser : CodeVisitor { return new SourceReference (this.current_source_file, begin, end); } + SourceReference get_src (SourceLocation begin, SourceLocation? end = null) { + var e = this.end; + if (end != null) { + e = end; + } + return new SourceReference (this.current_source_file, begin, e); + } + const string GIR_VERSION = "1.2"; static void add_symbol_to_container (Symbol container, Symbol sym) { @@ -2474,6 +2482,7 @@ public class Vala.GirParser : CodeVisitor { } Parameter parse_parameter (out int array_length_idx = null, out int closure_idx = null, out int destroy_idx = null, out string? scope = null, out Comment? comment = null, string? default_name = null) { + var begin = this.begin; Parameter param; array_length_idx = -1; @@ -2535,7 +2544,7 @@ public class Vala.GirParser : CodeVisitor { if (reader.name == "varargs") { start_element ("varargs"); next (); - param = new Parameter.with_ellipsis (get_current_src ()); + param = new Parameter.with_ellipsis (get_src (begin)); end_element ("varargs"); } else { string ctype; @@ -2556,7 +2565,7 @@ public class Vala.GirParser : CodeVisitor { ctype = null; } - param = new Parameter (name, type, get_current_src ()); + param = new Parameter (name, type, get_src (begin)); if (ctype != null) { param.set_attribute_string ("CCode", "type", ctype); }