/** * Helper function returns -1 if the line is empty else returns the * amount of whitespace pt is indented by */ private static int SkipWhitespace( EnvDTE.EditPoint pt) { int start = pt.DisplayColumn; while (!pt.AtEndOfLine && ((pt.GetText(1) == " ") || (pt.GetText(1) == "\t"))) { pt.CharRight(1); } if (pt.AtEndOfLine) { return -1; } else { return pt.DisplayColumn-start; } }
private static void SkipString(EnvDTE.EditPoint pt, string wanted) { string actual = GetTextOnLine(pt, wanted.Length); if (actual != wanted) { throw new System.ArgumentException("Error parsing expected string", wanted); } pt.CharRight(wanted.Length); }
private static void GoToEndOfPreviousWord( EnvDTE.EditPoint pt) { pt.CharLeft(1); while ((pt.GetText(1) != " ") && (pt.GetText(1) != "\t")) { pt.CharLeft(1); } while ((pt.GetText(1) == " ") || (pt.GetText(1) == "\t")) { pt.CharLeft(1); } pt.CharRight(1); }
private static void SkipColumns( EnvDTE.EditPoint pt, int blockIndentation) { int start = pt.DisplayColumn; int startLine = pt.Line; while ((pt.DisplayColumn-start) < blockIndentation) { pt.CharRight(1); if (pt.Line != startLine) { throw new System.ArgumentException("Error parsing columns"); } } if ((pt.DisplayColumn-start) != blockIndentation) { throw new System.ArgumentException("Error parsing columns"); } }
// pre: must be a word before the end of the line moves to the end of // the word private static void GoToEndOfNextWord( EnvDTE.EditPoint pt) { while ((pt.GetText(1) == " ") || (pt.GetText(1) == "\t")) { pt.CharRight(1); } while ((!pt.AtEndOfLine) && (pt.GetText(1) != " ") && (pt.GetText(1) != "\t")) { pt.CharRight(1); } }