get { return save_temps; }
}
- public Report report { get; set; default = new Report ();}
+ public Report report { get; set; }
public Method? entry_point { get; set; }
analyzer = new SemanticAnalyzer ();
flow_analyzer = new FlowAnalyzer ();
used_attr = new UsedAttr ();
+ report = new Report (this);
}
/**
*/
public void add_source_file (SourceFile file) {
if (source_files_map.contains (file.filename)) {
- Report.warning (null, "Ignoring source file `%s', which was already added to this context", file.filename);
+ report.log_warning (null, "Ignoring source file `%s', which was already added to this context", file.filename);
return;
}
path = get_gir_path (pkg);
}
if (path == null) {
- Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories", pkg);
+ report.log_error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories", pkg);
return false;
}
}
}
} catch (FileError e) {
- Report.error (null, "Unable to read dependency file: %s", e.message);
+ report.log_error (null, "Unable to read dependency file: %s", e.message);
return false;
}
*/
public bool add_source_filename (string filename, bool is_source = false, bool cmdline = false) {
if (!FileUtils.test (filename, FileTest.EXISTS)) {
- Report.error (null, "%s not found", filename);
+ report.log_error (null, "%s not found", filename);
return false;
}
} else if (filename.has_suffix (".h")) {
/* Ignore */
} else {
- Report.error (null, "%s is not a supported source file type. Only .vala, .vapi, .gs, and .c files are supported.", filename);
+ report.log_error (null, "%s is not a supported source file type. Only .vala, .vapi, .gs, and .c files are supported.", filename);
return false;
}
public void add_define (string define) {
if (is_defined (define)) {
- Report.warning (null, "`%s' is already defined", define);
+ report.log_warning (null, "`%s' is already defined", define);
if (/VALA_0_\d+/.match_all (define)) {
- Report.warning (null, "`VALA_0_XX' defines are automatically added up to current compiler version in use");
+ report.log_warning (null, "`VALA_0_XX' defines are automatically added up to current compiler version in use");
} else if (/GLIB_2_\d+/.match_all (define)) {
- Report.warning (null, "`GLIB_2_XX' defines are automatically added up to targeted glib version");
+ report.log_warning (null, "`GLIB_2_XX' defines are automatically added up to targeted glib version");
}
}
defines.add (define);
if (API_VERSION.scanf ("%d.%d", out api_major, out api_minor) != 2
|| api_major > 0
|| api_minor % 2 != 0) {
- Report.error (null, "Invalid format for Vala.API_VERSION");
+ report.log_error (null, "Invalid format for Vala.API_VERSION");
return;
}
glib_minor -= glib_minor % 2;
set_target_glib_version ("%d.%d".printf (glib_major, glib_minor));
} else {
- Report.warning (null, "Could not determine the version of `glib-2.0', target version of glib was not set");
+ report.log_warning (null, "Could not determine the version of `glib-2.0', target version of glib was not set");
}
return;
}
if (target_glib != null && target_glib.scanf ("%d.%d", out glib_major, out glib_minor) != 2
|| glib_minor % 2 != 0) {
- Report.error (null, "Only a stable version of GLib can be targeted, use MAJOR.MINOR format with MINOR as an even number");
+ report.log_error (null, "Only a stable version of GLib can be targeted, use MAJOR.MINOR format with MINOR as an even number");
}
if (glib_major != 2) {
- Report.error (null, "This version of valac only supports GLib 2");
+ report.log_error (null, "This version of valac only supports GLib 2");
}
if (glib_minor <= target_glib_minor) {
var stream = FileStream.open (filename, "w");
if (stream == null) {
- Report.error (null, "unable to open `%s' for writing", filename);
+ report.log_error (null, "unable to open `%s' for writing", filename);
return;
}
var stream = FileStream.open (filename, "w");
if (stream == null) {
- Report.error (null, "unable to open `%s' for writing", filename);
+ report.log_error (null, "unable to open `%s' for writing", filename);
return;
}
Process.spawn_command_line_sync (pc, null, null, out exit_status);
return (0 == exit_status);
} catch (SpawnError e) {
- Report.error (null, e.message);
+ report.log_error (null, e.message);
return false;
}
}
try {
Process.spawn_command_line_sync (pc, out output, null, out exit_status);
if (exit_status != 0) {
- Report.error (null, "%s exited with status %d", pkg_config_command, exit_status);
+ report.log_error (null, "%s exited with status %d", pkg_config_command, exit_status);
return null;
}
} catch (SpawnError e) {
- Report.error (null, e.message);
+ report.log_error (null, e.message);
output = null;
}
private unowned string quote_color_end = "";
+ protected CodeContext context;
protected int warnings;
protected int errors;
static GLib.Regex val_regex;
+ public Report (CodeContext ctx) {
+ context = ctx;
+ }
+
/**
* Set all colors by string
*
print_message (source, "error", error_color_start, error_color_end, message, verbose_errors);
}
+ /* Convenience methods for log errors and warnings*/
+ public void log_notice (SourceReference? source, string msg_format, ...) {
+ CodeContext.get ().report.note (source, msg_format.vprintf (va_list ()));
+ }
+ public void log_deprecated (SourceReference? source, string msg_format, ...) {
+ CodeContext.get ().report.depr (source, msg_format.vprintf (va_list ()));
+ }
+ public void log_experimental (SourceReference? source, string msg_format, ...) {
+ CodeContext.get ().report.depr (source, msg_format.vprintf (va_list ()));
+ }
+ public void log_warning (SourceReference? source, string msg_format, ...) {
+ CodeContext.get ().report.warn (source, msg_format.vprintf (va_list ()));
+ }
+ public void log_error (SourceReference? source, string msg_format, ...) {
+ CodeContext.get ().report.err (source, msg_format.vprintf (va_list ()));
+ }
+
/* Convenience methods calling warn and err on correct instance */
[PrintfFormat]
public static void notice (SourceReference? source, string msg_format, ...) {