summaryrefslogtreecommitdiff
path: root/Source/Dafny/Util.cs
diff options
context:
space:
mode:
authorGravatar Clément Pit--Claudel <clement.pitclaudel@live.com>2015-07-27 11:25:10 -0700
committerGravatar Clément Pit--Claudel <clement.pitclaudel@live.com>2015-07-27 11:25:10 -0700
commitc69d99690d9a25c448455df2bc8afee276b7b64c (patch)
tree4a2a33a644afd463911eb08735eefd15743b5842 /Source/Dafny/Util.cs
parent8a26fae8810b3a0419df1704de2b23926b95e92e (diff)
Clean up error reporting.
There now is one main entry point for reporting errors, warnings, or information. Next step is to make the VS extension use that.
Diffstat (limited to 'Source/Dafny/Util.cs')
-rw-r--r--Source/Dafny/Util.cs23
1 files changed, 23 insertions, 0 deletions
diff --git a/Source/Dafny/Util.cs b/Source/Dafny/Util.cs
index 63659696..6162d32c 100644
--- a/Source/Dafny/Util.cs
+++ b/Source/Dafny/Util.cs
@@ -67,6 +67,29 @@ namespace Microsoft.Dafny {
return res;
}
+ internal static void ReportIssue(string header, IToken tok, string msg, params object[] args) {
+ ReportIssue(header, tok, String.Format(msg, args));
+ }
+
+ internal static void ReportIssue(string header, IToken tok, string msg) {
+ ReportIssue(header, tok.filename, tok.line, tok.col, msg);
+ }
+
+ internal static void ReportIssue(string header, string filename, int line, int column, string msg) {
+ Console.WriteLine(ReportIssueToString(header, filename, line, column, msg));
+ }
+
+ internal static string ReportIssueToString(string header, string filename, int line, int column, string msg) {
+ Contract.Requires(header != null);
+ Contract.Requires(filename != null);
+ Contract.Requires(msg != null);
+ return ReportIssueToString_Bare(": " + header, filename, line, column, ": " + msg);
+ }
+
+ internal static string ReportIssueToString_Bare(string header, string filename, int line, int column, string msg) {
+ return String.Format("{0}({1},{2}){3}{4}", filename, line, column - 1, header, msg ?? "");
+ }
+
/// <summary>
/// Returns s but with all occurrences of '_' removed.
/// </summary>