ICSharpCode.NRefactory.CSharp.Completion.CSharpCompletionEngine.GetPreviousToken C# (CSharp) Method

GetPreviousToken() private method

private GetPreviousToken ( int &i, bool allowLineChange ) : string
i int
allowLineChange bool
return string
		string GetPreviousToken(ref int i, bool allowLineChange)
		{
			char c;
			if (i <= 0) {
				return null;
			}
			
			do {
				c = document.GetCharAt(--i);
			} while (i > 0 && char.IsWhiteSpace (c) && (allowLineChange ? true : c != '\n'));
			
			if (i == 0) {
				return null;
			}
			
			if (!char.IsLetterOrDigit(c)) {
				return new string(c, 1);
			}
			
			int endOffset = i + 1;
			
			do {
				c = document.GetCharAt(i - 1);
				if (!(char.IsLetterOrDigit(c) || c == '_')) {
					break;
				}
				
				i--;
			} while (i > 0);
			
			return document.GetText(i, endOffset - i);
		}