private static void FindTextTestHelper(int caretPosition, string inputText, string expectedResult)
        {
            var context = new IntellisenseProviderContext
                {
                    CaretPosition = caretPosition,
                    InputText = inputText,
                    DesiredResultSet = IntellisenseDesiredResultSet.Default
                };

            var search = context.FindTextToSearch();
            Assert.AreEqual(expectedResult, search);
        }
        public IList<IntellisenseProviderResult> GetIntellisenseResults(IntellisenseProviderContext context)
        {
            if(context == null)
            {
                return new List<IntellisenseProviderResult>();
            }

            var caretPosition = context.CaretPosition;
            var inputText = context.InputText ?? string.Empty;
            var parseEventLog = _syntaxTreeBuilderHelper.EventLog;
            var intellisenseDesiredResultSet = context.DesiredResultSet;

            if((caretPosition == 0 || string.IsNullOrEmpty(inputText))
                && intellisenseDesiredResultSet != IntellisenseDesiredResultSet.EntireSet)
            {
                return EmptyResults;
            }

            if(context.IsInCalculateMode)
            {
                if(intellisenseDesiredResultSet == IntellisenseDesiredResultSet.EntireSet)
                {
                    if(parseEventLog != null) parseEventLog.Clear();

                    if(_syntaxTreeBuilderHelper.EventLog != null && _syntaxTreeBuilderHelper.HasEventLogs)
                    {
                        List<IntellisenseProviderResult> tResults = new List<IntellisenseProviderResult>();
                        tResults.AddRange(IntellisenseResult);
                        return EvaluateEventLogs(tResults, inputText);
                    }

                    return IntellisenseResult;
                }

                Token[] tokens;
                if(intellisenseDesiredResultSet == IntellisenseDesiredResultSet.ClosestMatch)
                {
                    var searchText = context.FindTextToSearch();
                    _syntaxTreeBuilderHelper.Build(searchText, true, out tokens);
                    string sub = string.IsNullOrEmpty(searchText) ? inputText : searchText;

                    List<IntellisenseProviderResult> subResults = IntellisenseResult.Where(t => t.Name.StartsWith(sub)).ToList();

                    if(_syntaxTreeBuilderHelper.EventLog != null && _syntaxTreeBuilderHelper.HasEventLogs)
                    {
                        return EvaluateEventLogs(subResults, inputText);
                    }

                    return subResults;
                }

                _syntaxTreeBuilderHelper.Build(inputText, false, out tokens);

                if(_syntaxTreeBuilderHelper.HasEventLogs)
                {
                    return EvaluateEventLogs(inputText);
                }
            }

            return EmptyResults;
        }
        public IList<IIntellisenseResult> GetIntellisenseResultsImpl(IntellisenseProviderContext context)
        {
            string searchText = context.FindTextToSearch();
            var results = new List<IIntellisenseResult>();

            if (context.DesiredResultSet == IntellisenseDesiredResultSet.EntireSet)
            {
                results.AddRange(IntellisenseResults);
            }
            else if (!InLiteralRegion(context.InputText, context.CaretPosition))
            {
                var filteredResults = IntellisenseResults.Where(i => i.Option.DisplayValue.ToLower().StartsWith(searchText.ToLower()));
                results.AddRange(filteredResults);
            }
            return results;
        }