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



commit 6ff9ce6a0a5d3561851b3bac2bedc1fab12412c1
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 0c31ffc72..7bce26aed 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]