[vala/wip/ricotz/lsp-rev: 8/9] vala: Use some replacement an unavailable identifier string



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

    vala: Use some replacement an unavailable identifier string

 vala/valaparser.vala          |  2 +-
 vala/valasourcereference.vala | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index e0b8d5018..2f9cbb0f2 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -287,7 +287,7 @@ public class Vala.Parser : CodeVisitor {
                        if (context.keep_going) {
                                report_parse_error (e);
                                prev ();
-                               return "";
+                               return get_src (get_location ()).to_source_string ();
                        } else {
                                throw e;
                        }
diff --git a/vala/valasourcereference.vala b/vala/valasourcereference.vala
index 24aeeda45..746fb37ed 100644
--- a/vala/valasourcereference.vala
+++ b/vala/valasourcereference.vala
@@ -66,4 +66,14 @@ public class Vala.SourceReference {
        public string to_string () {
                return ("%s:%d.%d-%d.%d".printf (file.get_relative_filename (), begin.line, begin.column, 
end.line, end.column));
        }
+
+       /**
+        * Returns a string representation of this source reference
+        * which can be used as placeholder in our AST.
+        *
+        * @return source-compatible string
+        */
+       public string to_source_string () {
+               return ("S%d%d%d%d".printf (begin.line, begin.column, end.line, end.column));
+       }
 }


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