Remove debugging comment
[mono.git] / mcs / mcs / report.cs
index 3e1721bba47524f4233f59512b00a06719987a59..4adde10bfe732243f4dc1ef4490ae0632ae95c3a 100644 (file)
@@ -65,7 +65,7 @@ namespace Mono.CSharp {
                /// <summary>
                /// List of symbols related to reported error/warning. You have to fill it before error/warning is reported.
                /// </summary>
-               static StringCollection related_symbols = new StringCollection ();
+               static StringCollection extra_information = new StringCollection ();
 
                abstract class AbstractMessage {
 
@@ -76,6 +76,8 @@ namespace Mono.CSharp {
                                }
                        }
 
+                       public abstract bool IsWarning { get; }
+
                        public abstract string MessageType { get; }
 
                        public virtual void Print (int code, string location, string text)
@@ -89,18 +91,20 @@ namespace Mono.CSharp {
                                        msg.Append (' ');
                                }
                                msg.AppendFormat ("{0} CS{1:0000}: {2}", MessageType, code, text);
-                               Console.WriteLine (msg.ToString ());
+                               Console.Error.WriteLine (msg.ToString ());
 
-                               foreach (string s in related_symbols) {
-                                       Console.WriteLine (String.Concat (s, MessageType, ')'));
-                               }
-                               related_symbols.Clear ();
+                               foreach (string s in extra_information) 
+                                       Console.Error.WriteLine (s + MessageType);
+
+                               extra_information.Clear ();
 
                                if (Stacktrace)
                                        Console.WriteLine (FriendlyStackTrace (new StackTrace (true)));
 
-                               if (Fatal)
-                                       throw new Exception (text);
+                               if (Fatal) {
+                                       if (!IsWarning || WarningsAreErrors)
+                                               throw new Exception (text);
+                               }
 
                                Check (code);
                        }
@@ -127,6 +131,10 @@ namespace Mono.CSharp {
                                Level = level;
                        }
 
+                       public override bool IsWarning {
+                               get { return true; }
+                       }
+
                        bool IsEnabled (int code)
                        {
                                if (RootContext.WarningLevel < Level)
@@ -148,7 +156,7 @@ namespace Mono.CSharp {
                        public override void Print(int code, string location, string text)
                        {
                                if (!IsEnabled (code)) {
-                                       related_symbols.Clear ();
+                                       extra_information.Clear ();
                                        return;
                                }
 
@@ -182,6 +190,10 @@ namespace Mono.CSharp {
                                base.Print (code, location, text);
                        }
 
+                       public override bool IsWarning {
+                               get { return false; }
+                       }
+
                        public override string MessageType {
                                get {
                                        return "error";
@@ -238,11 +250,14 @@ namespace Mono.CSharp {
 
                // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                // IF YOU ADD A NEW WARNING YOU HAVE TO DUPLICATE ITS ID HERE
+               //
                public static bool IsValidWarning (int code)
                {
-                       int[] all_warnings = new int[] { 28, 67, 78, 105, 108, 109, 114, 192, 168, 169, 183, 184, 219, 251, 612, 618, 626, 628, 642, 649,
-                                                                                        659, 660, 661, 672, 1030, 1522, 1616, 1691, 1692, 1901, 2002, 2023, 3012, 3019, 8024, 8028
-                                                                                  };
+                       int[] all_warnings = new int[] {
+                               28, 67, 78, 105, 108, 109, 114, 192, 168, 169, 183, 184, 219, 251, 612, 618, 626, 628, 642, 649,
+                               659, 660, 661, 672, 1030, 1522, 1616, 1691, 1692, 1901, 2002, 2023, 3012, 3019, 8024, 8028
+                       };
+                       
                        foreach (int i in all_warnings) {
                                if (i == code)
                                        return true;
@@ -252,12 +267,12 @@ namespace Mono.CSharp {
                
                static public void LocationOfPreviousError (Location loc)
                {
-                       Console.WriteLine (String.Format ("{0}({1}) (Location of symbol related to previous error)", loc.Name, loc.Row));
+                       Console.Error.WriteLine (String.Format ("{0}({1}) (Location of symbol related to previous error)", loc.Name, loc.Row));
                }    
         
-               static public void RuntimeMissingSupport (string feature) 
+               static public void RuntimeMissingSupport (Location loc, string feature) 
                {
-                       Report.Error (-88, "Your .NET Runtime does not support '{0}'. Please use the latest Mono runtime instead.");
+                       Report.Error (-88, loc, "Your .NET Runtime does not support '{0}'. Please use the latest Mono runtime instead.", feature);
                }
 
                /// <summary>
@@ -303,7 +318,12 @@ namespace Mono.CSharp {
 
                static void SymbolRelatedToPreviousError (string loc, string symbol)
                {
-                       related_symbols.Add (String.Format ("{0}: '{1}' (name of symbol related to previous ", loc, symbol));
+                       extra_information.Add (String.Format ("{0}: '{1}' (name of symbol related to previous ", loc, symbol));
+               }
+
+               public static void ExtraInformation (Location loc, string msg)
+               {
+                       extra_information.Add (String.Format ("{0}({1}) {2}", loc.Name, loc.Row, msg));
                }
 
                public static WarningRegions RegisterWarningRegion (Location location)