[valadoc] error reporter improvements



commit 0b04a8cd0f0e99172125bd68e1312d4d522ea8a9
Author: Florian Brosch <flo brosch gmail com>
Date:   Mon Jul 11 23:15:38 2011 +0200

    error reporter improvements

 src/doclets/gtkdoc/commentconverter.vala           |    2 +-
 src/doclets/gtkdoc/dbus.vala                       |    2 +-
 src/doclets/gtkdoc/doclet.vala                     |   26 ++++++------
 src/doclets/gtkdoc/gcomment.vala                   |   42 ++++++++++----------
 src/doclets/gtkdoc/generator.vala                  |    4 +-
 src/doclets/gtkdoc/utils.vala                      |    2 +-
 src/libvaladoc/content/embedded.vala               |    2 +-
 .../documentation/documentationparser.vala         |    8 ++--
 src/libvaladoc/documentation/wiki.vala             |    4 +-
 src/libvaladoc/errorreporter.vala                  |   43 +++++++++++++++-----
 .../importer/valadocdocumentationimporter.vala     |    4 +-
 src/libvaladoc/parser/manyrule.vala                |    4 +-
 src/libvaladoc/parser/oneofrule.vala               |    2 +-
 src/libvaladoc/parser/parser.vala                  |   32 +++++++++++---
 src/libvaladoc/parser/parsercallback.vala          |    4 +-
 src/libvaladoc/parser/rule.vala                    |    4 +-
 src/libvaladoc/parser/sequencerule.vala            |    4 +-
 src/libvaladoc/parser/sourcelocation.vala          |    4 +-
 src/libvaladoc/parser/tokentype.vala               |    6 ++-
 src/libvaladoc/taglets/tagletlink.vala             |    2 +-
 src/libvaladoc/taglets/tagletsee.vala              |    2 +-
 src/libvaladoc/taglets/tagletthrows.vala           |    2 +-
 22 files changed, 125 insertions(+), 80 deletions(-)
---
diff --git a/src/doclets/gtkdoc/commentconverter.vala b/src/doclets/gtkdoc/commentconverter.vala
old mode 100644
new mode 100755
index 4192199..e520983
--- a/src/doclets/gtkdoc/commentconverter.vala
+++ b/src/doclets/gtkdoc/commentconverter.vala
@@ -144,7 +144,7 @@ public class Gtkdoc.CommentConverter : ContentVisitor {
 			break;
 
 		default:
-			reporter.simple_warning ("GtkDoc: unsupported list type: %s".printf (list.bullet.to_string ()));
+			reporter.simple_warning ("GtkDoc: unsupported list type: %s", list.bullet.to_string ());
 			break;
 		}
 
diff --git a/src/doclets/gtkdoc/dbus.vala b/src/doclets/gtkdoc/dbus.vala
old mode 100644
new mode 100755
index 45c8198..c49560b
--- a/src/doclets/gtkdoc/dbus.vala
+++ b/src/doclets/gtkdoc/dbus.vala
@@ -142,7 +142,7 @@ namespace Gtkdoc.DBus {
 			var xml_file = Path.build_filename (xml_dir, "%s.xml".printf (to_docbook_id (name)));
 			var writer = new TextWriter (xml_file, "w");
 			if (!writer.open ()) {
-				reporter.simple_error ("GtkDoc: unable to open %s for writing".printf (writer.filename));
+				reporter.simple_error ("GtkDoc: unable to open %s for writing", writer.filename);
 				return false;
 			}
 			writer.write_line (to_string (reporter));
diff --git a/src/doclets/gtkdoc/doclet.vala b/src/doclets/gtkdoc/doclet.vala
old mode 100644
new mode 100755
index fc9b30f..4845ba6
--- a/src/doclets/gtkdoc/doclet.vala
+++ b/src/doclets/gtkdoc/doclet.vala
@@ -57,7 +57,7 @@ namespace Gtkdoc.Config {
 			unowned string[] gtkdoc_args = args;
 			opt_context.parse (ref gtkdoc_args);
 		} catch (OptionError e) {
-			reporter.simple_error ("GtkDoc: Error: %s\nRun '-X --help' to see a full list of available command line options.".printf (e.message));
+			reporter.simple_error ("GtkDoc: Error: %s\nRun '-X --help' to see a full list of available command line options.", e.message);
 			return false;
 		}
 
@@ -155,7 +155,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
 		}
 
 		if (!copy_file (filename, Path.build_filename (comments_dir, Path.get_basename (filename)))) {
-			reporter.simple_error ("GtkDoc: Can't copy %s".printf (filename));
+			reporter.simple_error ("GtkDoc: Can't copy %s", filename);
 		}
 	}
 
@@ -186,7 +186,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
 			prepared += filename;
 
 			if (!FileUtils.test (filename, FileTest.EXISTS)) {
-				reporter.simple_error ("GtkDoc: %s not found".printf (relative_filename));
+				reporter.simple_error ("GtkDoc: %s not found", relative_filename);
 				continue;
 			}
 
@@ -195,7 +195,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
 			} else if (filename.has_suffix (".h")) {
 				prepare_h_file (filename);
 			} else {
-				reporter.simple_error ("GtkDoc: %s is not a supported source file type. Only .h, and .c files are supported.".printf (relative_filename));
+				reporter.simple_error ("GtkDoc: %s is not a supported source file type. Only .h, and .c files are supported.", relative_filename);
 			}
 		}
 
@@ -235,7 +235,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
 		try {
 			Process.spawn_sync (settings.path, args, null, SpawnFlags.SEARCH_PATH, null, null, null);
 		} catch (Error e) {
-			reporter.simple_error ("gtkdoc-scan: %s".printf (e.message));
+			reporter.simple_error ("gtkdoc-scan: %s", e.message);
 			return false;
 		}
 
@@ -277,7 +277,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
 			string cflags;
 			Process.spawn_sync (null, pc_cflags, null, SpawnFlags.SEARCH_PATH, null, out cflags, out stderr, out status);
 			if (status != 0) {
-				reporter.simple_error ("GtkDoc: pkg-config cflags error: %s".printf (stderr));
+				reporter.simple_error ("GtkDoc: pkg-config cflags error: %s", stderr);
 				return false;
 			}
 			cflags = cflags.strip ();
@@ -285,7 +285,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
 			string libs;
 			Process.spawn_sync (null, pc_libs, null, SpawnFlags.SEARCH_PATH, null, out libs, out stderr, out status);
 			if (status != 0) {
-				reporter.simple_error ("GtkDoc: pkg-config libs error: %s".printf (stderr));
+				reporter.simple_error ("GtkDoc: pkg-config libs error: %s", stderr);
 				return false;
 			}
 
@@ -309,7 +309,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
 
 			Process.spawn_sync (settings.path, args, env, SpawnFlags.SEARCH_PATH, null, null, null);
 		} catch (Error e) {
-			reporter.simple_error ("gtkdoc-scangobj: %s".printf (e.message));
+			reporter.simple_error ("gtkdoc-scangobj: %s", e.message);
 			return false;
 		}
 
@@ -332,7 +332,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
 		try {
 			Process.spawn_sync (settings.path, args, null, SpawnFlags.SEARCH_PATH, null, null, null);
 		} catch (Error e) {
-			reporter.simple_error ("gtkdoc-mkdb: %s".printf (e.message));
+			reporter.simple_error ("gtkdoc-mkdb: %s", e.message);
 			return false;
 		}
 
@@ -342,7 +342,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
 			try {
 				FileUtils.get_contents (main_file, out contents);
 			} catch (Error e) {
-				reporter.simple_error ("GtkDoc: Error while reading main file '%s' contents: %s".printf (main_file, e.message));
+				reporter.simple_error ("GtkDoc: Error while reading main file '%s' contents: %s", main_file, e.message);
 				return false;
 			}
 
@@ -374,7 +374,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
 			try {
 				FileUtils.set_contents (main_file, contents);
 			} catch (Error e) {
-				reporter.simple_error ("GtkDoc: Error while writing main file '%s' contents: %s".printf (main_file, e.message));
+				reporter.simple_error ("GtkDoc: Error while writing main file '%s' contents: %s", main_file, e.message);
 				return false;
 			}
 		}
@@ -396,7 +396,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
 						  settings.pkg_name, "../%s-docs.xml".printf (settings.pkg_name)},
 						null, SpawnFlags.SEARCH_PATH, null, null, null);
 		} catch (Error e) {
-			reporter.simple_error ("gtkdoc-mkhtml: %s".printf (e.message));
+			reporter.simple_error ("gtkdoc-mkhtml: %s", e.message);
 			return false;
 		}
 
@@ -409,7 +409,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
 						  "--html-dir", html_dir },
 						null, SpawnFlags.SEARCH_PATH, null, null, null);
 		} catch (Error e) {
-			reporter.simple_error ("gtkdoc-fixxref: %s".printf (e.message));
+			reporter.simple_error ("gtkdoc-fixxref: %s", e.message);
 			return false;
 		}
 
diff --git a/src/doclets/gtkdoc/gcomment.vala b/src/doclets/gtkdoc/gcomment.vala
old mode 100644
new mode 100755
index 6e686fa..3b5c8b6
--- a/src/doclets/gtkdoc/gcomment.vala
+++ b/src/doclets/gtkdoc/gcomment.vala
@@ -1,24 +1,24 @@
 /* gcomment.vala
-*
-* Copyright (C) 2010 Luca Bruno
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation; either
-* version 2.1 of the License, or (at your option) any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
-*
-* Author:
-* 	Luca Bruno <lethalman88 gmail com>
-*/
+ *
+ * Copyright (C) 2010 Luca Bruno
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ * 	Luca Bruno <lethalman88 gmail com>
+ */
 
 public class Gtkdoc.Header {
 	public string name;
@@ -149,7 +149,7 @@ public class Gtkdoc.GComment {
 			} else if (header.name == "Since") {
 				since = header.value;
 			} else {
-				reporter.simple_warning ("GtkDoc: Unknown versioning tag '%s'".printf (header.name));
+				reporter.simple_warning ("GtkDoc: Unknown versioning tag '%s'", header.name);
 			}
 		}
 
diff --git a/src/doclets/gtkdoc/generator.vala b/src/doclets/gtkdoc/generator.vala
old mode 100644
new mode 100755
index 950d57e..7b4974e
--- a/src/doclets/gtkdoc/generator.vala
+++ b/src/doclets/gtkdoc/generator.vala
@@ -68,7 +68,7 @@ public class Gtkdoc.Generator : Api.Visitor {
 
 		var sections_writer = new TextWriter (sections, "a");
 		if (!sections_writer.open ()) {
-			reporter.simple_error ("GtkDoc: unable to open %s for writing".printf (sections_writer.filename));
+			reporter.simple_error ("GtkDoc: unable to open %s for writing", sections_writer.filename);
 			return false;
 		}
 
@@ -78,7 +78,7 @@ public class Gtkdoc.Generator : Api.Visitor {
 			var cwriter = new TextWriter (Path.build_filename (code_dir, "%s.c".printf (basename)), "w");
 
 			if (!cwriter.open ()) {
-				reporter.simple_error ("GtkDoc: unable to open %s for writing".printf (cwriter.filename));
+				reporter.simple_error ("GtkDoc: unable to open %s for writing", cwriter.filename);
 				return false;
 			}
 
diff --git a/src/doclets/gtkdoc/utils.vala b/src/doclets/gtkdoc/utils.vala
old mode 100644
new mode 100755
index 250331e..942df9e
--- a/src/doclets/gtkdoc/utils.vala
+++ b/src/doclets/gtkdoc/utils.vala
@@ -172,7 +172,7 @@ namespace Gtkdoc {
 			Process.spawn_command_line_sync (pc, null, null, out exit_status);
 			return (0 == exit_status);
 		} catch (SpawnError e) {
-			reporter.simple_warning ("GtkDoc: Error pkg-config --exists %s: %s".printf (package_name, e.message));
+			reporter.simple_warning ("GtkDoc: Error pkg-config --exists %s: %s", package_name, e.message);
 			return false;
 		}
 	}
diff --git a/src/libvaladoc/api/array.vala b/src/libvaladoc/api/array.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/browsable.vala b/src/libvaladoc/api/browsable.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/class.vala b/src/libvaladoc/api/class.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/constant.vala b/src/libvaladoc/api/constant.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/delegate.vala b/src/libvaladoc/api/delegate.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/enum.vala b/src/libvaladoc/api/enum.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/enumvalue.vala b/src/libvaladoc/api/enumvalue.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/errorcode.vala b/src/libvaladoc/api/errorcode.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/errordomain.vala b/src/libvaladoc/api/errordomain.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/field.vala b/src/libvaladoc/api/field.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/formalparameter.vala b/src/libvaladoc/api/formalparameter.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/interface.vala b/src/libvaladoc/api/interface.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/item.vala b/src/libvaladoc/api/item.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/member.vala b/src/libvaladoc/api/member.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/method.vala b/src/libvaladoc/api/method.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/namespace.vala b/src/libvaladoc/api/namespace.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/node.vala b/src/libvaladoc/api/node.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/nodebuilder.vala b/src/libvaladoc/api/nodebuilder.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/package.vala b/src/libvaladoc/api/package.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/pointer.vala b/src/libvaladoc/api/pointer.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/property.vala b/src/libvaladoc/api/property.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/propertyaccessor.vala b/src/libvaladoc/api/propertyaccessor.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/signal.vala b/src/libvaladoc/api/signal.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/signaturebuilder.vala b/src/libvaladoc/api/signaturebuilder.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/struct.vala b/src/libvaladoc/api/struct.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/symbol.vala b/src/libvaladoc/api/symbol.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/tree.vala b/src/libvaladoc/api/tree.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/typeparameter.vala b/src/libvaladoc/api/typeparameter.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/typereference.vala b/src/libvaladoc/api/typereference.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/api/typesymbol.vala b/src/libvaladoc/api/typesymbol.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/charts/chart.vala b/src/libvaladoc/charts/chart.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/charts/chartfactory.vala b/src/libvaladoc/charts/chartfactory.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/charts/hierarchychart.vala b/src/libvaladoc/charts/hierarchychart.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/charts/simplechartfactory.vala b/src/libvaladoc/charts/simplechartfactory.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/content/embedded.vala b/src/libvaladoc/content/embedded.vala
index 527e9ca..e3be516 100755
--- a/src/libvaladoc/content/embedded.vala
+++ b/src/libvaladoc/content/embedded.vala
@@ -44,7 +44,7 @@ public class Valadoc.Content.Embedded : ContentElement, Inline, StyleAttributes
 
 	public override void check (Api.Tree api_root, Api.Node container, ErrorReporter reporter, Settings settings) {
 		if (!FileUtils.test (url, FileTest.EXISTS | FileTest.IS_REGULAR)) {
-			reporter.simple_error ("%s does not exist".printf (url));
+			reporter.simple_error ("%s does not exist", url);
 		} else {
 			package = container.package;
 		}
diff --git a/src/libvaladoc/ctyperesolver.vala b/src/libvaladoc/ctyperesolver.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/devhelp-markupwriter.vala b/src/libvaladoc/devhelp-markupwriter.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/documentation/commentscanner.vala b/src/libvaladoc/documentation/commentscanner.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/documentation/documentationparser.vala b/src/libvaladoc/documentation/documentationparser.vala
old mode 100644
new mode 100755
index 2753874..9de199b
--- a/src/libvaladoc/documentation/documentationparser.vala
+++ b/src/libvaladoc/documentation/documentationparser.vala
@@ -218,7 +218,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
 					((InlineContent) peek ()).content.add (_factory.create_text (" "));
 					return;
 				} else if (list.bullet != bullet) {
-					_parser.error ("Invalid bullet type '%s': expected '%s'".printf (bullet_type_string (bullet), bullet_type_string (list.bullet)));
+					_parser.error (null, "Invalid bullet type '%s': expected '%s'", bullet_type_string (bullet), bullet_type_string (list.bullet));
 					return;
 				}
 
@@ -278,7 +278,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
 	private void gir_append_link (Token token) throws ParserError {
 		var taglet = _factory.create_taglet ("link") as Taglets.Link;
 		if (!(taglet is Inline)) {
-			_parser.error ("Invalid taglet in this context: link");
+			_parser.error (null, "Invalid taglet in this context: link");
 		}
 		taglet.symbol_name = "c::"+token.to_string ();
 		push (taglet);
@@ -864,7 +864,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
 					TokenType.any_word ().action ((token) => {
 						var taglet = _factory.create_taglet (token.to_string ());
 						if (!(taglet is Inline)) {
-							_parser.error ("Invalid taglet in this context: %s".printf (token.to_string ()));
+							_parser.error (null, "Invalid taglet in this context: %s".printf (token.to_string ()));
 						}
 						push (taglet);
 						Rule? taglet_rule = taglet.get_parser_rule (multiline_run);
@@ -1229,7 +1229,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
 				TokenType.any_word ().action ((token) => {
 					var taglet = _factory.create_taglet (token.to_string ());
 					if (!(taglet is Block)) {
-						_parser.error ("Invalid taglet in this context", token);
+						_parser.error (token, "Invalid taglet in this context");
 					}
 					push (taglet);
 					Rule? taglet_rule = taglet.get_parser_rule (multiline_run);
diff --git a/src/libvaladoc/documentation/girdocumentationscanner.vala b/src/libvaladoc/documentation/girdocumentationscanner.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/documentation/wiki.vala b/src/libvaladoc/documentation/wiki.vala
index 33f77ad..7ac9461 100755
--- a/src/libvaladoc/documentation/wiki.vala
+++ b/src/libvaladoc/documentation/wiki.vala
@@ -68,7 +68,7 @@ public class Valadoc.WikiPage : Object, Documentation {
 			FileUtils.get_contents (this.path, out content);
 			this.documentation_str = content;
 		} catch (FileError err) {
-			reporter.simple_error ("Unable to read file `%s': %s".printf (this.path, err.message));
+			reporter.simple_error ("Unable to read file `%s': %s", this.path, err.message);
 		}
 	}
 
@@ -122,7 +122,7 @@ public class Valadoc.WikiPageTree : Object {
 				}
 			}
 		} catch (FileError err) {
-			reporter.simple_error ("Unable to open directory `%s': %s".printf (path, err.message));
+			reporter.simple_error ("Unable to open directory `%s': %s", path, err.message);
 		}
 	}
 
diff --git a/src/libvaladoc/documentation/wikiscanner.vala b/src/libvaladoc/documentation/wikiscanner.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/errorreporter.vala b/src/libvaladoc/errorreporter.vala
index cb88aa1..454d087 100755
--- a/src/libvaladoc/errorreporter.vala
+++ b/src/libvaladoc/errorreporter.vala
@@ -55,11 +55,26 @@ public class Valadoc.ErrorReporter : Object {
 
 	private enum ErrorType {
 		WARNING,
-		ERROR
+		ERROR;
+
+		public string to_string () {
+			switch (this) {
+			case ErrorType.WARNING:
+				return "warning";
+
+			case ErrorType.ERROR:
+				return "error";
+			}
+
+			assert_not_reached ();
+		}
 	}
 
-	private inline void msg (ErrorType type, string file, long line, long startpos, long endpos, string errline, string msg) {
-		this.stream.printf ("%s:%lu.%lu-%lu.%lu: %s: %s\n", file, line, startpos, line, endpos, (type == ErrorType.ERROR)? "error" : "warning", msg);
+	private inline void msg (ErrorType type, string file, long line, long startpos, long endpos, string errline, string msg_format, va_list args) {
+		this.stream.printf ("%s:%lu.%lu-%lu.%lu: %s: ", file, line, startpos, line, endpos, type.to_string ());
+		this.stream.vprintf (msg_format, args);
+		this.stream.putc ('\n');
+
 		if (startpos <= endpos) {
 			this.stream.printf ("%s\n", errline);
 			for (int i = 0; i < errline.char_count ()+1; i++) {
@@ -75,25 +90,31 @@ public class Valadoc.ErrorReporter : Object {
 		}
 	}
 
-	public void simple_warning (string msg) {
-		this.stream.puts (msg);
+	public void simple_warning (string msg_format, ...) {
+		var args = va_list();
+		this.stream.vprintf (msg_format, args);
 		this.stream.putc ('\n');
 		this._warnings++;
 	}
 
-	public void simple_error (string msg) {
-		this.stream.puts (msg);
+	public void simple_error (string msg_format, ...) {
+		var args = va_list();
+		this.stream.vprintf (msg_format, args);
 		this.stream.putc ('\n');
 		this._errors++;
 	}
 
-	public void error (string file, long line, long startpos, long endpos, string errline, string msg) {
-		this.msg (ErrorType.ERROR, file, line, startpos, endpos, errline, msg);
+	//TODO
+	public void error (string file, long line, long startpos, long endpos, string errline, string msg_format, ...) {
+		var args = va_list();
+		this.msg (ErrorType.ERROR, file, line, startpos, endpos, errline, msg_format, args);
 		this._errors++;
 	}
 
-	public void warning (string file, long line, long startpos, long endpos, string errline, string msg) {
-		this.msg (ErrorType.WARNING, file, line, startpos, endpos, errline, msg);
+	//TODO
+	public void warning (string file, long line, long startpos, long endpos, string errline, string msg_format, ...) {
+		var args = va_list();
+		this.msg (ErrorType.WARNING, file, line, startpos, endpos, errline, msg_format, args);
 		this._warnings++;
 	}
 }
diff --git a/src/libvaladoc/html/htmlchartfactory.vala b/src/libvaladoc/html/htmlchartfactory.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/html/linkhelper.vala b/src/libvaladoc/html/linkhelper.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/importer/documentationimporter.vala b/src/libvaladoc/importer/documentationimporter.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/importer/girdocumentationbuilder.vala b/src/libvaladoc/importer/girdocumentationbuilder.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/importer/girdocumentationimporter.vala b/src/libvaladoc/importer/girdocumentationimporter.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/importer/valadocdocumentationimporter.vala b/src/libvaladoc/importer/valadocdocumentationimporter.vala
old mode 100644
new mode 100755
index c35bd37..189acf7
--- a/src/libvaladoc/importer/valadocdocumentationimporter.vala
+++ b/src/libvaladoc/importer/valadocdocumentationimporter.vala
@@ -121,7 +121,7 @@ public class Valadoc.Importer.ValadocDocumentationImporter : DocumentationImport
 		}
 
 		if (symbol == null) {
-			reporter.simple_warning ("%s does not exist".printf (symbol_name));
+			reporter.simple_warning ("%s does not exist", symbol_name);
 			return ;
 		}
 
@@ -142,7 +142,7 @@ public class Valadoc.Importer.ValadocDocumentationImporter : DocumentationImport
 				_parser.parse ((string) content, filename, 0, 0);
 			}
 		} catch (FileError err) {
-			reporter.simple_error ("Unable to map file `%s': %s".printf (filename, err.message));
+			reporter.simple_error ("Unable to map file `%s': %s", filename, err.message);
 		} catch (ParserError err) {
 		}
 	}
diff --git a/src/libvaladoc/importer/valadocdocumentationimporterscanner.vala b/src/libvaladoc/importer/valadocdocumentationimporterscanner.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/markupwriter.vala b/src/libvaladoc/markupwriter.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/parser/manyrule.vala b/src/libvaladoc/parser/manyrule.vala
old mode 100644
new mode 100755
index 9543c4f..40bf627
--- a/src/libvaladoc/parser/manyrule.vala
+++ b/src/libvaladoc/parser/manyrule.vala
@@ -78,9 +78,9 @@ internal class Valadoc.ManyRule : Rule {
 		}
 
 		if (_scheme is TokenType) {
-			parser.error ("expected %s".printf (((TokenType) _scheme).to_pretty_string ()), token);
+			parser.error (null, "expected %s", ((TokenType) _scheme).to_pretty_string ());
 		} else {
-			parser.error ("unexpected token", token);
+			parser.error (token, "unexpected token");
 		}
 		assert_not_reached ();
 	}
diff --git a/src/libvaladoc/parser/oneofrule.vala b/src/libvaladoc/parser/oneofrule.vala
old mode 100644
new mode 100755
index 4d4a793..19e9419
--- a/src/libvaladoc/parser/oneofrule.vala
+++ b/src/libvaladoc/parser/oneofrule.vala
@@ -70,7 +70,7 @@ internal class Valadoc.OneOfRule : Rule {
 			return false;
 		}
 
-		parser.error ("unexpected token", token);
+		parser.error (token, "unexpected token");
 		assert_not_reached ();
 	}
 
diff --git a/src/libvaladoc/parser/optionalrule.vala b/src/libvaladoc/parser/optionalrule.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/parser/parser.vala b/src/libvaladoc/parser/parser.vala
old mode 100644
new mode 100755
index 6bc0167..49147e2
--- a/src/libvaladoc/parser/parser.vala
+++ b/src/libvaladoc/parser/parser.vala
@@ -69,7 +69,7 @@ public class Valadoc.Parser : ParserCallback {
 			_scanner.end ();
 
 			if (rule_stack.size != 0) {
-				error ("Rule stack is not empty!");
+				error (null, "Rule stack is not empty!");
 			}
 		} catch (ParserError e) {
 			#if DEBUG
@@ -100,7 +100,7 @@ public class Valadoc.Parser : ParserCallback {
 
 			// Check for invalid recursion
 			if (rule_depth != rule_stack.size && peek_rule () == rule) {
-				error ("Parser state error");
+				error (null, "Parser state error");
 				break;
 			}
 			rule = peek_rule ();
@@ -224,8 +224,16 @@ public class Valadoc.Parser : ParserCallback {
 		return false;
 	}
 
-	public void warning (string message, Token? token = null) {
-		string error_message = message + (token != null ? ": " + token.to_pretty_string () : "");
+	public void warning (Token? token, string message, ...) {
+		va_list args = va_list ();
+		string error_message;
+
+		if (token == null) {
+			error_message = message.vprintf (args) + ": " + token.to_pretty_string ();
+		} else {
+			error_message = message;
+		}
+
 		_reporter.warning (_filename,
 		                   get_line (token),
 		                   get_start_column (token),
@@ -234,13 +242,23 @@ public class Valadoc.Parser : ParserCallback {
 		                   error_message);
 	}
 
-	public void error (string message, Token? token = null) throws ParserError {
-		string error_message = message + (token != null ? ": " + token.to_pretty_string () : "");
-		_reporter.error (_filename, get_line (token),
+	public void error (Token? token, string message, ...) throws ParserError {
+		va_list args = va_list ();
+		string error_message;
+
+		if (token == null) {
+			error_message = message.vprintf (args) + ": " + token.to_pretty_string ();
+		} else {
+			error_message = message;
+		}
+
+		_reporter.error (_filename,
+						 get_line (token),
 		                 get_start_column (token),
 		                 get_end_column (token),
 		                 _scanner.get_line_content (),
 		                 error_message);
+
 		throw new ParserError.UNEXPECTED_TOKEN (error_message);
 	}
 
diff --git a/src/libvaladoc/parser/parsercallback.vala b/src/libvaladoc/parser/parsercallback.vala
old mode 100644
new mode 100755
index a0526e2..a3d6792
--- a/src/libvaladoc/parser/parsercallback.vala
+++ b/src/libvaladoc/parser/parsercallback.vala
@@ -32,6 +32,6 @@ public interface Valadoc.ParserCallback {
 	public abstract bool would_parent_accept_token (Token token);
 	public abstract bool would_parent_reduce_to_rule (Token token, Rule rule);
 
-	public abstract void warning (string message, Token? token = null);
-	public abstract void error (string message, Token? token = null) throws ParserError;
+	public abstract void warning (Token? token, string message, ...);
+	public abstract void error (Token? token, string message, ...) throws ParserError;
 }
diff --git a/src/libvaladoc/parser/rule.vala b/src/libvaladoc/parser/rule.vala
old mode 100644
new mode 100755
index 76cffc2..b75e39a
--- a/src/libvaladoc/parser/rule.vala
+++ b/src/libvaladoc/parser/rule.vala
@@ -84,7 +84,9 @@ public abstract class Valadoc.Rule : Object {
 	}
 
 	public enum Forward {
-		NONE, PARENT, CHILD
+		NONE,
+		PARENT,
+		CHILD
 	}
 
 	public abstract bool is_optional ();
diff --git a/src/libvaladoc/parser/scanner.vala b/src/libvaladoc/parser/scanner.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/parser/sequencerule.vala b/src/libvaladoc/parser/sequencerule.vala
old mode 100644
new mode 100755
index b2f9d5a..39bc620
--- a/src/libvaladoc/parser/sequencerule.vala
+++ b/src/libvaladoc/parser/sequencerule.vala
@@ -103,9 +103,9 @@ internal class Valadoc.SequenceRule : Rule {
 		}
 
 		if (scheme_element is TokenType) {
-			parser.error ("expected %s".printf (((TokenType) scheme_element).to_pretty_string ()), token);
+			parser.error (token, "expected %s", ((TokenType) scheme_element).to_pretty_string ());
 		} else {
-			parser.error ("unexpected token", token);
+			parser.error (token, "unexpected token");
 		}
 		assert_not_reached ();
 	}
diff --git a/src/libvaladoc/parser/sourcelocation.vala b/src/libvaladoc/parser/sourcelocation.vala
old mode 100644
new mode 100755
index 3418e71..51b5bc1
--- a/src/libvaladoc/parser/sourcelocation.vala
+++ b/src/libvaladoc/parser/sourcelocation.vala
@@ -6,12 +6,12 @@
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
-
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
-
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
diff --git a/src/libvaladoc/parser/stubrule.vala b/src/libvaladoc/parser/stubrule.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/parser/token.vala b/src/libvaladoc/parser/token.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/parser/tokentype.vala b/src/libvaladoc/parser/tokentype.vala
old mode 100644
new mode 100755
index 871cf0b..9d98b1c
--- a/src/libvaladoc/parser/tokentype.vala
+++ b/src/libvaladoc/parser/tokentype.vala
@@ -256,7 +256,11 @@ public class Valadoc.TokenType : Object {
 	private TokenType (string string_value, int basic_value, Action? action) {
 		_string_value = string_value;
 		_basic_value = basic_value;
-		_action = action;
+		if (_action != null) {
+			_action = (token) => { action (token); };
+		} else {
+			_action = null;
+		}
 	}
 
 	private TokenType.basic (string string_value, string? pretty_string = null) {
diff --git a/src/libvaladoc/taglets/tagletinit.vala b/src/libvaladoc/taglets/tagletinit.vala
old mode 100644
new mode 100755
diff --git a/src/libvaladoc/taglets/tagletlink.vala b/src/libvaladoc/taglets/tagletlink.vala
index d7fba14..0d61bc3 100755
--- a/src/libvaladoc/taglets/tagletlink.vala
+++ b/src/libvaladoc/taglets/tagletlink.vala
@@ -48,7 +48,7 @@ public class Valadoc.Taglets.Link : InlineTaglet {
 
 		if (_symbol == null) {
 			// TODO use ContentElement's source reference
-			reporter.simple_warning ("%s does not exist".printf (symbol_name));
+			reporter.simple_warning ("%s does not exist", symbol_name);
 		}
 
 		base.check (api_root, container, reporter, settings);
diff --git a/src/libvaladoc/taglets/tagletsee.vala b/src/libvaladoc/taglets/tagletsee.vala
index bea41d5..b33e522 100755
--- a/src/libvaladoc/taglets/tagletsee.vala
+++ b/src/libvaladoc/taglets/tagletsee.vala
@@ -47,7 +47,7 @@ public class Valadoc.Taglets.See : ContentElement, Taglet, Block {
 
 		if (symbol == null) {
 			// TODO use ContentElement's source reference
-			reporter.simple_warning ("%s does not exist".printf (symbol_name));
+			reporter.simple_warning ("%s does not exist", symbol_name);
 		}
 	}
 
diff --git a/src/libvaladoc/taglets/tagletthrows.vala b/src/libvaladoc/taglets/tagletthrows.vala
index 25b6525..b58e4e3 100755
--- a/src/libvaladoc/taglets/tagletthrows.vala
+++ b/src/libvaladoc/taglets/tagletthrows.vala
@@ -39,7 +39,7 @@ public class Valadoc.Taglets.Throws : InlineContent, Taglet, Block {
 		error_domain = api_root.search_symbol_str (container, error_domain_name);
 		if (error_domain == null) {
 			// TODO use ContentElement's source reference
-			reporter.simple_error ("%s does not exist".printf (error_domain_name));
+			reporter.simple_error ("%s does not exist", error_domain_name);
 		}
 
 		base.check (api_root, container, reporter, settings);



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