]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girparser: Improve source_reference of parameters
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 20 Jan 2020 11:45:03 +0000 (12:45 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 20 Jan 2020 15:29:13 +0000 (16:29 +0100)
vala/valagirparser.vala

index 17b41b1e556e37edb8cfdcfa6431bb7d8d361f5a..f30d8b0d5967c9c2b0091f72ea642c6c7e2877b1 100644 (file)
@@ -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);
                        }