Ejemplo n.º 1
0
        public static void Run(DTE environment, VsError selectedError)
        {
            if (selectedError == null)
            {
                throw new ArgumentNullException("selectedError", @"Selected error is null");
            }

            selectedError.Navigate();

            // Replace all items that have spaces before the ending brackets
            // "A closing parenthesis should never be preceded by whitespace."
            ErrorUtilities.RegExUpdateWholeDocument(@"\s+\)", ")", selectedError, environment);

            // "If the closing parenthesis is followed by whitespace, the next non-whitespace character must not be an opening or closing parenthesis or square bracket,
            //  or a semicolon or comma."
            ErrorUtilities.RegExUpdateWholeDocument(@"\)\s+;", @");", selectedError, environment);
            ErrorUtilities.RegExUpdateWholeDocument(@"\)\s+,", @"),", selectedError, environment);
            ErrorUtilities.RegExUpdateWholeDocument(@"\)\s+\(", @")(", selectedError, environment);
            ErrorUtilities.RegExUpdateWholeDocument(@"\)\s+\)", @"))", selectedError, environment);
            ErrorUtilities.RegExUpdateWholeDocument(@"\)\s+\[", @")\[", selectedError, environment);
            ErrorUtilities.RegExUpdateWholeDocument(@"\)\s+\]", @")\]", selectedError, environment);

            // replace all items that have a cariage return between each line
            ErrorUtilities.RegExUpdateWholeDocument(@"(\s+[a-zA-Z]+\))\s*\r\n(\).*)", "$1$2", selectedError, environment);

            // In most cases, a closing parenthesis should be followed by a single space, unless the closing parenthesis comes at the end of a cast,
            // or the closing parenthesis is followed by certain types of operator symbols, such as positive signs, negative signs, and colons.
        }
Ejemplo n.º 2
0
        public static void Run(DTE dte, VsError selectedError)
        {
            selectedError.Navigate();

            /*
             * A violation of this rule occurs when the preprocessor-type keyword in a preprocessor directive is preceded by space
             */
            ErrorUtilities.RegExUpdateWholeDocument(@"#[^\S\n]+(\w)", "#$1", selectedError, dte);
        }
Ejemplo n.º 3
0
        public static void Run(DTE dte, VsError selectedError)
        {
            selectedError.Navigate();

            /*
             * A violation of this rule occurs when the opening parenthesis within a statement is not spaced correctly.
             * An opening parenthesis should not be preceded by any whitespace, unless it is the first character on the line, or it is preceded
             * by certain C# keywords such as if, while, or for. In addition, an opening parenthesis is allowed to be preceded by whitespace when
             * it follows an operator symbol within an expression.
             *
             * An opening parenthesis should not be followed by whitespace, unless it is the last character on the line.
             */
            ErrorUtilities.RegExUpdateWholeDocument(@"\([^\S\n]+", "(", selectedError, dte);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Attempt to fix the error via regular expression updates
 /// </summary>
 /// <param name="dte">Design time environment the update is taking place in</param>
 /// <param name="selectedError">The error that we are trying to fix</param>
 public static void Run(DTE dte, VsError selectedError)
 {
     ErrorUtilities.RegExUpdateWholeDocument(@"(\s+)[System\.]*Array(\s+)", "$1array$2", selectedError, dte);
     ErrorUtilities.RegExUpdateWholeDocument(@"(\s+)[System\.]*Boolean(\s+)", "$1bool$2", selectedError, dte);
     ErrorUtilities.RegExUpdateWholeDocument(@"(\s+)[System\.]*Byte(\s+)", "$1byte$2", selectedError, dte);
     ErrorUtilities.RegExUpdateWholeDocument(@"(\s+)[System\.]*Char(\s+)", "$1char$2", selectedError, dte);
     ErrorUtilities.RegExUpdateWholeDocument(@"(\s+)[System\.]*Decimal(\s+)", "$1decimal$2", selectedError, dte);
     ErrorUtilities.RegExUpdateWholeDocument(@"(\s+)[System\.]*Double(\s+)", "$1double$2", selectedError, dte);
     ErrorUtilities.RegExUpdateWholeDocument(@"(\s+)[System\.]*Int16(\s+)", "$1short$2", selectedError, dte);
     ErrorUtilities.RegExUpdateWholeDocument(@"(\s+)[System\.]*Int32(\s+)", "$1int$2", selectedError, dte);
     ErrorUtilities.RegExUpdateWholeDocument(@"(\s+)[System\.]*Int64(\s+)", "$1long$2", selectedError, dte);
     ErrorUtilities.RegExUpdateWholeDocument(@"(\s+)[System\.]*Object(\s+)", "$1object$2", selectedError, dte);
     ErrorUtilities.RegExUpdateWholeDocument(@"(\s+)[System\.]*SByte(\s+)", "$1sbyte$2", selectedError, dte);
     ErrorUtilities.RegExUpdateWholeDocument(@"(\s+)[System\.]*Single(\s+)", "$1single$2", selectedError, dte);
     ErrorUtilities.RegExUpdateWholeDocument(@"(\s+)[System\.]*UInt16(\s+)", "$1ushort$2", selectedError, dte);
     ErrorUtilities.RegExUpdateWholeDocument(@"(\s+)[System\.]*UInt32(\s+)", "$1uint$2", selectedError, dte);
     ErrorUtilities.RegExUpdateWholeDocument(@"(\s+)[System\.]*UInt64(\s+)", "$1ulong$2", selectedError, dte);
     ErrorUtilities.RegExUpdateWholeDocument(@"(\s+)[System\.]*String(\s+)", "$1string$2", selectedError, dte);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Attempt to fix the error via regular expression updates
 /// </summary>
 /// <param name="dte">Design time environment the update is taking place in</param>
 /// <param name="selectedError">The error that we are trying to fix</param>
 public static void Run(DTE dte, VsError selectedError)
 {
     ErrorUtilities.RegExUpdateWholeDocument(@"""", "string.Empty", selectedError, dte);
 }
Ejemplo n.º 6
0
 public static void Run(DTE dte, VsError selectedItem)
 {
     selectedItem.Navigate();
     ErrorUtilities.RegExUpdateWholeDocument(@"^(\s*\t*\r\n\s*\t*){1,}$", string.Empty, selectedItem, dte);
 }
Ejemplo n.º 7
0
 public static void Run(DTE environment, VsError selectedError)
 {
     selectedError.Navigate();
     ErrorUtilities.RegExUpdateWholeDocument(@"\/\/([^\/\s])", "// $1", selectedError, environment);
 }