private MemberType GetSuggestedMemberType(int index, IReverseTokenizer revTokenizer, bool onlyVerifyEmptyContext = false)
        {
            var enumerator = revTokenizer.GetReversedTokens().Where(x => x.SourceSpan.Start.Index < index).GetEnumerator();

            while (true)
            {
                if (!enumerator.MoveNext())
                {
                    return(MemberType.None);
                }

                var tokInfo = enumerator.Current;
                if (tokInfo.Equals(default(TokenInfo)) ||
                    tokInfo.Token.Kind == TokenKind.NewLine ||
                    tokInfo.Token.Kind == TokenKind.NLToken ||
                    tokInfo.Token.Kind == TokenKind.Comment)
                {
                    continue;   // linebreak
                }
                // Look for the token in the context map
                ContextEntry contextEntry;
                if (ContextCompletionMap.Instance.TryGetValue(tokInfo.Token.Kind, out contextEntry) ||
                    ContextCompletionMap.Instance.TryGetValue(tokInfo.Category, out contextEntry))
                {
                    var matchContainer = new ContextPossibilityMatchContainer(contextEntry, this);
                    IEnumerable <ContextPossibility> matchingPossibilities;
                    if (matchContainer.TryMatchContextPossibility(tokInfo.SourceSpan.Start.Index, revTokenizer, out matchingPossibilities))
                    {
                        if (onlyVerifyEmptyContext)
                        {
                            return(MemberType.None);
                        }
                        else
                        {
                            MemberType result = MemberType.None;
                            foreach (var matchedPossible in matchingPossibilities)
                            {
                                if (matchedPossible.SetProviders.Length > 0)
                                {
                                    result |= matchedPossible.SetProviders.Select(x => x.ReturningTypes).Aggregate((x, y) => x | y);
                                }
                            }
                            return(result);
                        }
                    }

                    return(MemberType.All);
                }
                else
                {
                    // we don't have the token in our context map, so return
                    return(MemberType.None);
                }
            }
        }
        private bool DetermineContext(int index, IReverseTokenizer revTokenizer, List <MemberResult> memberList, bool onlyVerifyEmptyContext = false)
        {
            var enumerator = revTokenizer.GetReversedTokens().Where(x => x.SourceSpan.Start.Index < index).GetEnumerator();

            while (true)
            {
                if (!enumerator.MoveNext())
                {
                    return(false);
                }

                var tokInfo = enumerator.Current;
                if (tokInfo.Equals(default(TokenInfo)) ||
                    tokInfo.Token.Kind == TokenKind.NewLine ||
                    tokInfo.Token.Kind == TokenKind.NLToken ||
                    tokInfo.Token.Kind == TokenKind.Comment)
                {
                    continue;   // linebreak
                }
                // Look for the token in the context map
                ContextEntry contextEntry;
                if (ContextCompletionMap.Instance.TryGetValue(tokInfo.Token.Kind, out contextEntry) ||
                    ContextCompletionMap.Instance.TryGetValue(tokInfo.Category, out contextEntry))
                {
                    var matchContainer = new ContextPossibilityMatchContainer(contextEntry, this);
                    IEnumerable <ContextPossibility> matchingPossibilities;
                    if (matchContainer.TryMatchContextPossibility(tokInfo.SourceSpan.Start.Index, revTokenizer, out matchingPossibilities))
                    {
                        if (onlyVerifyEmptyContext)
                        {
                            return(matchingPossibilities.All(x => x.SingleTokens.Length == 0 && x.SetProviders.Length == 0));
                        }
                        else
                        {
                            foreach (var matchedPossible in matchingPossibilities)
                            {
                                LoadPossibilitySet(index, matchedPossible, memberList);
                            }
                        }
                    }

                    return(true);
                }
                else
                {
                    // we don't have the token in our context map, so return
                    return(false);
                }
            }
        }