[vala/wip/issue/764] vala: Output multiline source-reference




commit 2e03fc91b6962f93b3a84bc69b3ec52377de7e17
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Tue Mar 5 21:15:24 2019 +0100

    vala: Output multiline source-reference
    
    Fixes https://gitlab.gnome.org/GNOME/vala/issues/764

 vala/valareport.vala | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/vala/valareport.vala b/vala/valareport.vala
index 0aad89f15..8e480f03d 100644
--- a/vala/valareport.vala
+++ b/vala/valareport.vala
@@ -233,19 +233,29 @@ public class Vala.Report {
         */
        private void report_source (SourceReference source) {
                if (source.begin.line != source.end.line) {
-                       // FIXME Cannot report multi-line issues currently
+                       int idx;
+                       for (idx = source.begin.line - 2; idx < source.end.line + 2; ++idx) {
+                               string offending_line = source.file.get_source_line (idx);
+                               if (source.begin.line <= idx <= source.end.line) {
+                                       stderr.puts (caret_color_start);
+                                       stderr.printf (" >");
+                                       stderr.puts (caret_color_end);
+                               }
+                               stderr.printf ("  %s\n", offending_line);
+                       }
                        return;
                }
 
                string offending_line = source.file.get_source_line (source.begin.line);
 
                if (offending_line != null) {
-                       stderr.printf ("%s\n", offending_line);
+                       stderr.printf ("  %s\n", offending_line);
                        int idx;
 
                        /* We loop in this manner so that we don't fall over on differing
                         * tab widths. This means we get the ^s in the right places.
                         */
+                       stderr.printf ("  ");
                        for (idx = 1; idx < source.begin.column; ++idx) {
                                if (offending_line[idx - 1] == '\t') {
                                        stderr.printf ("\t");


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