~ubuntu-branches/ubuntu/saucy/monodevelop/saucy-proposed

« back to all changes in this revision

Viewing changes to contrib/ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2012-06-22 20:35:35 UTC
  • mfrom: (10.3.2)
  • Revision ID: package-import@ubuntu.com-20120622203535-zrozwvcf6kfk6l6i
Tags: 3.0.3.2+dfsg-1
* [3fd89ae] Imported Upstream version 3.0.3.2+dfsg
* [379a680] Remove old patches we haven't used for ages from git.
* [d71161d] Remove correct_paths_in_monodevelop-core-addins.pc.patch.
  Upstream claim to have fixed this by moving assembly install locations.
* [15dbfb9] Fix install location for MonoDevelop.Gettext.dll.config.
* [26eb434] Fix install location for MonoDevelop.SourceEditor2.dll.config.
* [4169974] Upstream commit 53282c9 which finally reconciles the 
  MonoDevelop.Gettext.dll install location with the 
  monodevelop-core-addins.pc location.

Show diffs side-by-side

added added

removed removed

Lines of Context:
565
565
                        source_file_index.Add (path, unit.Index);
566
566
                }
567
567
 
568
 
                void AddWarningAsError (string warningId, CompilerSettings settings)
569
 
                {
570
 
                        int id;
571
 
                        try {
572
 
                                id = int.Parse (warningId);
573
 
                        } catch {
574
 
                                report.CheckWarningCode (warningId, Location.Null);
575
 
                                return;
576
 
                        }
577
 
 
578
 
                        if (!report.CheckWarningCode (id, Location.Null))
579
 
                                return;
580
 
 
581
 
                        settings.AddWarningAsError (id);
582
 
                }
583
 
 
584
 
                void RemoveWarningAsError (string warningId, CompilerSettings settings)
585
 
                {
586
 
                        int id;
587
 
                        try {
588
 
                                id = int.Parse (warningId);
589
 
                        } catch {
590
 
                                report.CheckWarningCode (warningId, Location.Null);
591
 
                                return;
592
 
                        }
593
 
 
594
 
                        if (!report.CheckWarningCode (id, Location.Null))
595
 
                                return;
596
 
 
597
 
                        settings.AddWarningOnly (id);
 
568
                public bool ProcessWarningsList (string text, Action<int> action)
 
569
                {
 
570
                        bool valid = true;
 
571
                        foreach (string wid in text.Split (numeric_value_separator)) {
 
572
                                int id;
 
573
                                if (!int.TryParse (wid, NumberStyles.AllowLeadingWhite, CultureInfo.InvariantCulture, out id)) {
 
574
                                        report.Error (1904, "`{0}' is not a valid warning number", wid);
 
575
                                        valid = false;
 
576
                                        continue;
 
577
                                }
 
578
 
 
579
                                if (report.CheckWarningCode (id, Location.Null))
 
580
                                        action (id);
 
581
                        }
 
582
 
 
583
                        return valid;
598
584
                }
599
585
 
600
586
                void Error_RequiresArgument (string option)
997
983
                                        settings.WarningsAreErrors = true;
998
984
                                        parser_settings.WarningsAreErrors = true;
999
985
                                } else {
1000
 
                                        foreach (string wid in value.Split (numeric_value_separator))
1001
 
                                                AddWarningAsError (wid, settings);
 
986
                                        if (!ProcessWarningsList (value, v => settings.AddWarningAsError (v)))
 
987
                                                return ParseResult.Error;
1002
988
                                }
1003
989
                                return ParseResult.Success;
1004
990
 
1006
992
                                if (value.Length == 0) {
1007
993
                                        settings.WarningsAreErrors = false;
1008
994
                                } else {
1009
 
                                        foreach (string wid in value.Split (numeric_value_separator))
1010
 
                                                RemoveWarningAsError (wid, settings);
 
995
                                        if (!ProcessWarningsList (value, v => settings.AddWarningOnly (v)))
 
996
                                                return ParseResult.Error;
1011
997
                                }
1012
998
                                return ParseResult.Success;
1013
999
 
1014
1000
                        case "/warn":
 
1001
                        case "/w":
1015
1002
                                if (value.Length == 0) {
1016
1003
                                        Error_RequiresArgument (option);
1017
1004
                                        return ParseResult.Error;
1021
1008
                                return ParseResult.Success;
1022
1009
 
1023
1010
                        case "/nowarn":
1024
 
                                        if (value.Length == 0) {
1025
 
                                                Error_RequiresArgument (option);
1026
 
                                                return ParseResult.Error;
1027
 
                                        }
1028
 
 
1029
 
                                        var warns = value.Split (numeric_value_separator);
1030
 
                                        foreach (string wc in warns) {
1031
 
                                                try {
1032
 
                                                        if (wc.Trim ().Length == 0)
1033
 
                                                                continue;
1034
 
 
1035
 
                                                        int warn = Int32.Parse (wc);
1036
 
                                                        if (warn < 1) {
1037
 
                                                                throw new ArgumentOutOfRangeException ("warn");
1038
 
                                                        }
1039
 
                                                        settings.SetIgnoreWarning (warn);
1040
 
                                                } catch {
1041
 
                                                        report.Error (1904, "`{0}' is not a valid warning number", wc);
1042
 
                                                        return ParseResult.Error;
1043
 
                                                }
1044
 
                                        }
1045
 
                                        return ParseResult.Success;
 
1011
                                if (value.Length == 0) {
 
1012
                                        Error_RequiresArgument (option);
 
1013
                                        return ParseResult.Error;
 
1014
                                }
 
1015
 
 
1016
                                if (!ProcessWarningsList (value, v => settings.SetIgnoreWarning (v)))
 
1017
                                        return ParseResult.Error;
 
1018
 
 
1019
                                return ParseResult.Success;
1046
1020
 
1047
1021
                        case "/noconfig":
1048
1022
                                settings.LoadDefaultReferences = false;