[gnome-builder] snippets: return an error if we failed to parse a snippet



commit fc522223cb024339bdbca796001b3509c7e1ebe0
Author: Christian Hergert <chergert redhat com>
Date:   Fri Mar 11 16:41:53 2016 -0800

    snippets: return an error if we failed to parse a snippet

 libide/ide-source-snippet-parser.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-source-snippet-parser.c b/libide/ide-source-snippet-parser.c
index 40ee602..1cf5996 100644
--- a/libide/ide-source-snippet-parser.c
+++ b/libide/ide-source-snippet-parser.c
@@ -40,6 +40,8 @@ struct _IdeSourceSnippetParser
   GString *snippet_text;
 
   GFile   *current_file;
+
+  guint    had_error : 1;
 };
 
 G_DEFINE_TYPE (IdeSourceSnippetParser, ide_source_snippet_parser, G_TYPE_OBJECT)
@@ -504,6 +506,7 @@ ide_source_snippet_parser_feed_line (IdeSourceSnippetParser *parser,
     default:
       g_signal_emit (parser, signals [PARSING_ERROR], 0,
                      parser->current_file, parser->lineno, line);
+      parser->had_error = TRUE;
       break;
     }
 
@@ -543,6 +546,17 @@ ide_source_snippet_parser_load_from_file (IdeSourceSnippetParser *parser,
   g_set_object (&parser->current_file, file);
 
 again:
+  if (parser->had_error)
+    {
+      /* TODO: Better error messages */
+      g_set_error (error,
+                   G_IO_ERROR,
+                   G_IO_ERROR_INVALID_DATA,
+                   "%s:%d: invalid snippet",
+                   basename, parser->lineno);
+      return FALSE;
+    }
+
   line = g_data_input_stream_read_line_utf8 (data_stream, NULL, NULL, &local_error);
   if (!line && local_error)
     {


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