internal ICollection GetExpressionCompletions(string expressionString) { try { IntellisenseParser intellisenseParser = new IntellisenseParser(expressionString); ParserContext parserContext = intellisenseParser.BackParse(); if (parserContext != null) { Token token = parserContext.CurrentToken; // Check to see if the only relevant token (there's always an EndOfInput padded // at the end) is an identifier with only one character. if (parserContext.NumTokens == 2 && token.TokenID == TokenID.Identifier) { string ident = (string)token.Value; System.Diagnostics.Debug.Assert(parserContext.NextToken().TokenID == TokenID.EndOfInput); if (ident.Length == 1) { // The postfix expression consisted of a single character which was the beginning // of an identifier or keyword. Don't parse anything; just return all the root completions. return GetRootCompletions(ident[0]); } // Otherwise, we don't do anything. } else { // We have a set of tokens we need to parse to figure out what's going on. validation.Errors.Clear(); ParsePostfixExpression(parserContext, true, ValueCheck.Read); return parserContext.completions; } } } catch (RuleSyntaxException ex) { // Just ignore these, but when this happens, the completion list will be null. if (ex.ErrorNumber != 0) return null; } return null; }
internal ICollection GetExpressionCompletions(string expressionString) { try { ParserContext parserContext = new IntellisenseParser(expressionString).BackParse(); if (parserContext != null) { Token currentToken = parserContext.CurrentToken; if ((parserContext.NumTokens == 2) && (currentToken.TokenID == TokenID.Identifier)) { string str = (string) currentToken.Value; if (str.Length == 1) { return this.GetRootCompletions(str[0]); } } else { this.validation.Errors.Clear(); this.ParsePostfixExpression(parserContext, true, ValueCheck.Read); return parserContext.completions; } } } catch (RuleSyntaxException exception) { if (exception.ErrorNumber != 0) { return null; } } return null; }