Exemplo n.º 1
0
        public static void Run(DTE dte, VsError error)
        {
            error.Navigate();
            EditPoint2 ep = ErrorUtilities.GetEditPoint(dte);

            ep.StartOfLine();
            string variableName  = error.Description.Split(" ".ToCharArray())[7];
            string replaceString = ep.GetLines(ep.Line, ep.Line + 1);

            replaceString = Regex.Replace(replaceString, string.Format(@"(\s|\(|\!)({0})(\W)", variableName), "$1this.$2$3",
                                          RegexOptions.None);
            ep.ReplaceText(ep.LineLength, replaceString, (int )vsEPReplaceTextOptions.vsEPReplaceTextAutoformat);
        }
Exemplo n.º 2
0
        public static void RegExUpdate(string findPattern, string replacePattern, VsError selectedError, DTE dte)
        {
            selectedError.Navigate();
            EditPoint2 ep = GetEditPoint(dte);

            ep.StartOfLine();
            string textToUpdate = ep.GetLines(ep.Line, ep.Line + 1);

            textToUpdate = Regex.Replace(textToUpdate, findPattern, replacePattern);

            // Using the Autoformat option is cheating a little but saves on a lot of work.  It basically formats
            // the text as if you were typing it in the IDE
            ep.ReplaceText(ep.LineLength, textToUpdate, (int)vsEPReplaceTextOptions.vsEPReplaceTextAutoformat);
        }
Exemplo n.º 3
0
        public static void Run(DTE dte, VsError selectedError)
        {
            selectedError.Navigate();
            EditPoint2 ep = ErrorUtilities.GetEditPoint(dte);

            ep.StartOfLine();
            string testString = ep.GetLines(ep.Line, ep.Line + 1);

            if (Regex.Match(testString, @"\t").Success)
            {
                testString = Regex.Replace(testString, @"\t", @"    ");
                ep.ReplaceText(ep.LineLength, testString, (int)vsEPReplaceTextOptions.vsEPReplaceTextAutoformat);
            }
        }
Exemplo n.º 4
0
        public static void Run(DTE dte, VsError selectedError)
        {
            selectedError.Navigate();
            EditPoint2 ep = ErrorUtilities.GetEditPoint(dte);

            ep.StartOfLine();
            string editLine = ep.GetLines(ep.Line, ep.Line + 1);

            editLine = editLine.Replace(";", "");
            string varName = string.Empty;

            if (editLine.IndexOf("=") > -1)
            {
                varName = editLine.Split("=".ToCharArray()).First().Split(" ".ToCharArray()).Where(item => item.Length > 0).Last();
            }
            else
            {
                varName = editLine.Split(" ".ToCharArray()).Last();
            }
            ep.Parent.Selection.CharRight(Count: editLine.IndexOf(varName));
            dte.ExecuteCommand("Refactor.Rename");
            //// todo
        }