[gtk/wip/matthiasc/builder-fixes: 157/159] gtk-builder-tool: More helpful error messages



commit a7d81347d29d40dc53d0287dddce30e3e8c4c2d1
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Dec 13 02:05:11 2019 -0500

    gtk-builder-tool: More helpful error messages
    
    Include line numbers in the error messages we
    report, so it is possible to find the error.

 gtk/tools/gtk-builder-tool-simplify.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/gtk/tools/gtk-builder-tool-simplify.c b/gtk/tools/gtk-builder-tool-simplify.c
index 03cb931107..3cd917f2cd 100644
--- a/gtk/tools/gtk-builder-tool-simplify.c
+++ b/gtk/tools/gtk-builder-tool-simplify.c
@@ -35,6 +35,9 @@ struct Element {
   char **attribute_values;
   char *data;
   GList *children;
+
+  int line_number;
+  int char_number;
 };
 
 static void
@@ -77,6 +80,8 @@ start_element (GMarkupParseContext  *context,
   elt->attribute_names = g_strdupv ((char **)attribute_names);
   elt->attribute_values = g_strdupv ((char **)attribute_values);
 
+  g_markup_parse_context_get_position (context, &elt->line_number, &elt->char_number);
+
   if (data->current)
     data->current->children = g_list_append (data->current->children, elt);
   data->current = elt;
@@ -446,7 +451,7 @@ value_is_default (Element      *element,
 
   if (!gtk_builder_value_from_string (data->builder, pspec, value_string, &value, &error))
     {
-      g_printerr (_("%s: Couldn’t parse value for %s: %s\n"), data->input_filename, pspec->name, 
error->message);
+      g_printerr (_("%s:%d: Couldn’t parse value for property '%s': %s\n"), data->input_filename, 
element->line_number, pspec->name, error->message);
       g_error_free (error);
       ret = FALSE;
     }
@@ -639,8 +644,8 @@ property_can_be_omitted (Element      *element,
         "Layout "
       };
 
-      g_printerr (_("%s: %sproperty %s::%s not found\n"),
-                  data->input_filename, kind_str[kind], class_name, property_name);
+      g_printerr (_("%s:%d: %sproperty %s::%s not found\n"),
+                  data->input_filename, element->line_number, kind_str[kind], class_name, property_name);
       return FALSE;
     }
 


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