private static bool IsWordPart(char ch) { if (TextUtilities.IsLetterDigitOrUnderscore(ch)) { return(true); } return(ch == '.'); }
public static int FindWordStart(IDocument document, int offset) { int num = document.GetLineSegmentForOffset(offset).Offset; while (offset > num && TextUtilities.IsLetterDigitOrUnderscore(document.GetCharAt(offset - 1))) { offset--; } return(offset); }
public static int FindWordEnd(IDocument document, int offset) { LineSegment lineSegmentForOffset = document.GetLineSegmentForOffset(offset); int num = lineSegmentForOffset.Offset + lineSegmentForOffset.Length; while (offset < num && TextUtilities.IsLetterDigitOrUnderscore(document.GetCharAt(offset))) { offset++; } return(offset); }
public static TextUtilities.CharacterType GetCharacterType(char c) { if (TextUtilities.IsLetterDigitOrUnderscore(c)) { return(TextUtilities.CharacterType.LetterDigitOrUnderscore); } if (char.IsWhiteSpace(c)) { return(TextUtilities.CharacterType.WhiteSpace); } return(TextUtilities.CharacterType.Other); }
public static string GetExpressionBeforeOffset(TextArea textArea, int initialOffset) { IDocument document = textArea.Document; int num = initialOffset; while (num - 1 > 0) { char charAt = document.GetCharAt(num - 1); if (charAt <= ')') { if (charAt > '\r') { if (charAt == '\"') { if (num < initialOffset - 1) { return(null); } return("\"\""); } switch (charAt) { case '\'': { if (num < initialOffset - 1) { return(null); } return("'a'"); } case ')': { num = TextUtilities.SearchBracketBackward(document, num - 2, '(', ')'); continue; } } } else if (charAt == '\n' || charAt == '\r') { break; } } else if (charAt <= '>') { if (charAt == '.') { num--; continue; } else if (charAt == '>') { if (document.GetCharAt(num - 2) != '-') { break; } num -= 2; continue; } } else if (charAt == ']') { num = TextUtilities.SearchBracketBackward(document, num - 2, '[', ']'); continue; } else if (charAt == '}') { break; } if (!char.IsWhiteSpace(document.GetCharAt(num - 1))) { int num1 = num - 1; if (TextUtilities.IsLetterDigitOrUnderscore(document.GetCharAt(num1))) { while (num1 > 0 && TextUtilities.IsLetterDigitOrUnderscore(document.GetCharAt(num1 - 1))) { num1--; } string str = document.GetText(num1, num - num1).Trim(); string str1 = str; string str2 = str1; if (str1 != null && (str2 == "ref" || str2 == "out" || str2 == "in" || str2 == "return" || str2 == "throw" || str2 == "case") || str.Length > 0 && !TextUtilities.IsLetterDigitOrUnderscore(str[0])) { break; } num = num1; } else { break; } } else { num--; } } if (num < 0) { return(string.Empty); } string str3 = document.GetText(num, textArea.Caret.Offset - num).Trim(); int num2 = str3.LastIndexOf('\n'); if (num2 >= 0) { num = num + num2 + 1; } string str4 = document.GetText(num, textArea.Caret.Offset - num).Trim(); return(str4); }