2005-05-31 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mcs / mcs / report.cs
index 7e624fde0829ea204efa4f861ebd1d5b8c59a413..6e6603a689462c824cb261f6abc6d2956eac75f0 100644 (file)
@@ -10,6 +10,7 @@
 // FIXME: currently our class library does not support custom number format strings
 //
 using System;
+using System.IO;
 using System.Text;
 using System.Collections;
 using System.Collections.Specialized;
@@ -47,6 +48,8 @@ namespace Mono.CSharp {
                ///   Whether to dump a stack trace on errors. 
                /// </summary>
                static public bool Stacktrace;
+
+               static public TextWriter Stderr = Console.Error;
                
                //
                // If the 'expected' error code is reported then the
@@ -68,6 +71,14 @@ namespace Mono.CSharp {
                /// </summary>
                static StringCollection extra_information = new StringCollection ();
 
+               public static void Reset ()
+               {
+                       Errors = Warnings = 0;
+                       WarningsAreErrors = false;
+                       warning_ignore_table = null;
+                       warning_regions_table = null;
+               }
+
                abstract class AbstractMessage {
 
                        static void Check (int code)
@@ -92,10 +103,10 @@ namespace Mono.CSharp {
                                        msg.Append (' ');
                                }
                                msg.AppendFormat ("{0} CS{1:0000}: {2}", MessageType, code, text);
-                               Console.Error.WriteLine (msg.ToString ());
+                               Stderr.WriteLine (msg.ToString ());
 
                                foreach (string s in extra_information) 
-                                       Console.Error.WriteLine (s + MessageType);
+                                       Stderr.WriteLine (s + MessageType);
 
                                extra_information.Clear ();
 
@@ -271,7 +282,7 @@ namespace Mono.CSharp {
                
                static public void LocationOfPreviousError (Location loc)
                {
-                       Console.Error.WriteLine (String.Format ("{0}({1}) (Location of symbol related to previous error)", loc.Name, loc.Row));
+                       Stderr.WriteLine (String.Format ("{0}({1}) (Location of symbol related to previous error)", loc.Name, loc.Row));
                }    
         
                static public void RuntimeMissingSupport (Location loc, string feature) 
@@ -300,8 +311,7 @@ namespace Mono.CSharp {
                                        return;
                                }
 
-                               string name = String.Concat (temp_ds.Name, ".", mi.Name);
-                               MemberCore mc = temp_ds.GetDefinition (name);
+                               MemberCore mc = temp_ds.GetDefinition (mi.Name);
                                SymbolRelatedToPreviousError (mc);
                        }
                }
@@ -378,8 +388,12 @@ namespace Mono.CSharp {
 
                static public void Error (int code, Location loc, string format, params object[] args)
                {
-                       ErrorMessage e = new ErrorMessage ();
-                       e.Print (code, loc, String.Format (format, args));
+                       Error (code, loc, String.Format (format, args));
+               }
+
+               static public void Error (int code, Location loc, string error)
+               {
+                       new ErrorMessage ().Print (code, loc, error);
                }
 
                static public void SetIgnoreWarning (int code)