[vala/staging] girparser: Improve source_reference of parameters



commit 69ea76f8cb6d7863557e75b786530708c5d55b93
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Mon Jan 20 12:45:03 2020 +0100

    girparser: Improve source_reference of parameters

 vala/valagirparser.vala | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
---
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);
                        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]