[vala/wip/ricotz/lsp-rev: 1/8] DON'T MERGE vala: Add sanity check for SourceReference



commit 62d740107ea37c3a49d06efe107b0fd6a3531ca6
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Jan 18 20:03:37 2020 +0100

    DON'T MERGE vala: Add sanity check for SourceReference

 vala/valasourcereference.vala | 12 ++++++++++++
 1 file changed, 12 insertions(+)
---
diff --git a/vala/valasourcereference.vala b/vala/valasourcereference.vala
index 24aeeda45..dd8fac6a4 100644
--- a/vala/valasourcereference.vala
+++ b/vala/valasourcereference.vala
@@ -64,6 +64,18 @@ public class Vala.SourceReference {
         * @return human-readable string
         */
        public string to_string () {
+               // FIXME DON'T MERGE THIS
+               if (begin.line > end.line) {
+                       Report.warning (this, "bad line reference");
+                       assert_not_reached ();
+               } else if (begin.line == end.line && begin.column > end.column) {
+                       Report.warning (this, "bad column reference");
+                       assert_not_reached ();
+               } else if (begin.pos > end.pos) {
+                       Report.warning (this, "bad file position reference");
+                       assert_not_reached ();
+               }
+
                return ("%s:%d.%d-%d.%d".printf (file.get_relative_filename (), begin.line, begin.column, 
end.line, end.column));
        }
 }


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