コード例 #1
0
        public IList<IntellisenseProviderResult> GetIntellisenseResults(IntellisenseProviderContext context)
        {
            if(context == null)
            {
                return new List<IntellisenseProviderResult>();
            }

            IList<IIntellisenseResult> oldResults = GetIntellisenseResultsImpl(context);
            
            var results = new List<IntellisenseProviderResult>();

            if (oldResults != null)
            {
                foreach (IIntellisenseResult currentResult in oldResults)
                {
                    if (currentResult.ErrorCode != enIntellisenseErrorCode.None)
                    {
                        if (currentResult.Type == enIntellisenseResultType.Error && currentResult.IsClosedRegion)
                        {
                            results.Add(new IntellisenseProviderResult(this, currentResult.Option.DisplayValue, currentResult.Message, currentResult.Message, true));
                        }
                    }

                    if (currentResult.Type == enIntellisenseResultType.Selectable)
                    {
                        results.Add(new IntellisenseProviderResult(this, currentResult.Option.DisplayValue, currentResult.Option.Description, currentResult.Option.Description, false));
                    }
                }
            }

            return results;
        }
コード例 #2
0
        public IList<IntellisenseProviderResult> GetIntellisenseResults(IntellisenseProviderContext context)
        {
            if (context == null)
            {
                return new List<IntellisenseProviderResult>();
            }

            var results = new List<IntellisenseProviderResult>();
            if(context.DesiredResultSet == IntellisenseDesiredResultSet.EntireSet)
            {
                FileSystemQuery.QueryList("");
                FileSystemQuery.QueryCollection.ForEach(s => IntellisenseResults.Add(new IntellisenseProviderResult(this, s, string.Empty, string.Empty, false)));
                results.AddRange(IntellisenseResults);
            }
            else
            {
                if(!InLiteralRegion(context.InputText, context.CaretPosition))
                {
                    IntellisenseResults.Clear();
                    var regions = context.InputText.Split(' ');
                    var sum = 0;
                    string searchText = regions.Select(a => new { a, a.Length }).TakeWhile(a =>
                        {
                            sum = sum + context.CaretPosition;
                            return sum >= context.CaretPosition;
                        }).Last().a;
                    FileSystemQuery.QueryList(searchText);
                    FileSystemQuery.QueryCollection.ForEach(s => IntellisenseResults.Add(new IntellisenseProviderResult(this, s, string.Empty, string.Empty, false)));
                    results.AddRange(IntellisenseResults);
                }
            }
            return results;
        }
コード例 #3
0
        public string PerformResultInsertion(string input, IntellisenseProviderContext context)
        {
            VerifyArgument.IsNotNull("Context",context);
           
            string inputText = context.InputText ?? string.Empty;
            int caretPosition = context.CaretPosition;  

            if (caretPosition < 0 || caretPosition>inputText.Length)
                return string.Empty;

            var regions = inputText.Split(' '); // we can safely do this because the default provider handles the language features

            var sum = 0;
            int items = 0;
            var regionsText = regions.Select(a => new { a, a.Length }).TakeWhile(a =>
            {
                sum = sum + a.Length;
                items++;
                return sum <= caretPosition || items==1;
            }).Select(a => a.a).ToList();
            regionsText[regionsText.Count - 1] = input;// set caret region to replacement text

            var prefix = regionsText.Aggregate("", (a, b) => a + " " + b).TrimStart(' '); // fold back together
            context.CaretPositionOnPopup = prefix.Length;
            context.CaretPosition = prefix.Length;
            int i = 0;
            var inner = regions.SkipWhile(a =>
                {
                    i = i + 1;
                    return i < regionsText.Count + 1;
                }).Aggregate("", (a, b) => a + " " + b);
            return (prefix + inner).TrimEnd();

        }
コード例 #4
0
        public void CalculateIntellisenseProvider_GetIntellisenseResults_CalculateModeIsFalse_ResultCountIsZero()
        {
            var context = new IntellisenseProviderContext
                {
                    CaretPosition = 2,
                    InputText = "se",
                    IsInCalculateMode = false,
                    DesiredResultSet = IntellisenseDesiredResultSet.ClosestMatch
                };

            CalculateIntellisenseProvider calculateIntellisenseProvider = GetCalculateProvider(false);
            IList<IntellisenseProviderResult> results = calculateIntellisenseProvider.GetIntellisenseResults(context);
            Assert.AreEqual(0, results.Count);
        }
        public void CalculateIntellisenseProvider_GetIntellisenseResults_DesiredIsEntireSet_ResultAllResult()
        {
            var context = new IntellisenseProviderContext
                {
                    CaretPosition = 2,
                    InputText = "se",
                    IsInCalculateMode = true,
                    DesiredResultSet = IntellisenseDesiredResultSet.EntireSet
                };

            CalculateIntellisenseProvider calculateIntellisenseProvider = GetCalculateProvider(false);
            IList<IntellisenseProviderResult> results = calculateIntellisenseProvider.GetIntellisenseResults(context);

            Assert.AreEqual(175, results.Count);
        }
        public void DateTimeIntellisenseProvider_GetIntellisenseResults_PartialMethodMatch_ClosestMatchesReturned()
        {
            var context = new IntellisenseProviderContext
                {
                    CaretPosition = 1,
                    InputText = "d",
                    IsInCalculateMode = false,
                    DesiredResultSet = IntellisenseDesiredResultSet.ClosestMatch
                };

            var dateTimeIntellisenseProvider = new DateTimeIntellisenseProvider();
            IList<IntellisenseProviderResult> results = dateTimeIntellisenseProvider.GetIntellisenseResults(context);

            Assert.AreEqual(6, results.Count);
        }
コード例 #7
0
        public void FileSystemIntellisenseProvider_ExecuteInsertion(int caretPosition, string inputText, string inserted, string expected)
        {
            //------------Setup for test--------------------------
            var fileSystemIntellisenseProvider = new FileSystemIntellisenseProvider();

            //------------Execute Test---------------------------
            var context = new IntellisenseProviderContext
            {
                CaretPosition = caretPosition,
                InputText = inputText,
                IsInCalculateMode = false,
                DesiredResultSet = IntellisenseDesiredResultSet.ClosestMatch
            };

               var resp =  fileSystemIntellisenseProvider.PerformResultInsertion(inserted, context);
            //------------Assert Results-------------------------
            Assert.AreEqual(resp, expected);
        }
        public void CalculateIntellisenseProvider_GetIntellisenseResults_InputBeginsCaretPositonedAfterTwoCharacters_ResultsFilteredBasedOnCharacters()
        {
            var context = new IntellisenseProviderContext
                {
                    CaretPosition = 2,
                    InputText = "se",
                    IsInCalculateMode = true,
                    DesiredResultSet = IntellisenseDesiredResultSet.ClosestMatch
                };

            CalculateIntellisenseProvider calculateIntellisenseProvider = GetCalculateProvider(false);
            IList<IntellisenseProviderResult> results = calculateIntellisenseProvider.GetIntellisenseResults(context);

            Assert.AreEqual(4, results.Count);
            Assert.AreEqual("search", results[0].Name);
            Assert.AreEqual("searchb", results[1].Name);
            Assert.AreEqual("second", results[2].Name);
            Assert.AreEqual("seriessum", results[3].Name);
        }
コード例 #9
0
 public IList<IntellisenseProviderResult> GetIntellisenseResults(IntellisenseProviderContext context)
 {
     var results = new List<IntellisenseProviderResult>();
     if(context.DesiredResultSet == IntellisenseDesiredResultSet.EntireSet)
     {
         FileSystemQuery.QueryList("");
         FileSystemQuery.QueryCollection.ForEach(s => _intellisenseResults.Add(new IntellisenseProviderResult(this, s, string.Empty, string.Empty, false)));
         results.AddRange(_intellisenseResults);
     }
     else
     {
         if(!InLiteralRegion(context.InputText, context.CaretPosition))
         {
             _intellisenseResults.Clear();
             string searchText = context.InputText; //context.InputText.Substring(context.CaretPositionOnPopup, (context.CaretPosition - context.CaretPositionOnPopup));
             FileSystemQuery.QueryList(searchText);
             FileSystemQuery.QueryCollection.ForEach(s => _intellisenseResults.Add(new IntellisenseProviderResult(this, s, string.Empty, string.Empty, false)));
             results.AddRange(_intellisenseResults);
         }
     }
     return results;
 }
コード例 #10
0
 public string PerformResultInsertion(string input, IntellisenseProviderContext context)
 {
     throw new NotSupportedException();
 }
コード例 #11
0
        public void GetIntellisenseResultsWithOpenRegionAndInRecSetIndexAndWithFieldExpectedAllResults()
        {
            var context = new IntellisenseProviderContext
            {
                CaretPosition = 9,
                InputText = "[[City([[).Name]]",
                DesiredResultSet = IntellisenseDesiredResultSet.Default
            };

            var getResults = new DefaultIntellisenseProvider().GetIntellisenseResults(context);

            Assert.AreEqual(9, getResults.Count);
            Assert.AreEqual("[[Scalar]]", getResults[0].ToString());
            Assert.AreEqual("[[Country]]", getResults[1].ToString());
            Assert.AreEqual("[[State]]", getResults[2].ToString());
            Assert.AreEqual("[[City(", getResults[3].ToString());
            Assert.AreEqual("[[City().Name]]", getResults[4].ToString());
            Assert.AreEqual("[[City(*).Name]]", getResults[5].ToString());
            Assert.AreEqual("[[City().GeoLocation]]", getResults[6].ToString());
            Assert.AreEqual("[[City(*).GeoLocation]]", getResults[7].ToString());
            Assert.AreEqual("Invalid Expression", getResults[8].ToString());
        }
コード例 #12
0
        public void GetIntellisenseResultsWithInRecSetIndexAndWithFieldAndWithClosingSquareBraceExpectedNoResults()
        {
            var context = new IntellisenseProviderContext
            {
                CaretPosition = 13,
                InputText = "[[City([[sca]).Name]]",
                DesiredResultSet = IntellisenseDesiredResultSet.Default
            };

            var getResults = new DefaultIntellisenseProvider().GetIntellisenseResults(context);

            Assert.AreEqual("Invalid expression: Opening and closing brackets dont match.", getResults[0].Description);
        }
コード例 #13
0
 public void GetIntellisenseResultsWhereCarretPositionLessThanZeroExpectedNoResultsAndException()
 {
     var context = new IntellisenseProviderContext
     {
         CaretPosition = -1,
         InputText = "Sum([[Scalar]],",
         DesiredResultSet = IntellisenseDesiredResultSet.Default
     };
     var getResults = new DefaultIntellisenseProvider().GetIntellisenseResults(context);
     Assert.AreEqual(0, getResults.Count);
 }
コード例 #14
0
        public void GetIntellisenseResultsWhereCommaEnteredForInfragisticsFunctonExpectedNoResultsAndException()
        {
            var context = new IntellisenseProviderContext
            {
                CaretPosition = 15,
                InputText = "Sum([[Scalar]],",
                DesiredResultSet = IntellisenseDesiredResultSet.Default
            };

            var getResults = new DefaultIntellisenseProvider().GetIntellisenseResults(context);

            Assert.AreEqual(0, getResults.Count);
        }
コード例 #15
0
        public void GetIntellisenseResultsWithSumAndAfterCommaAndBeforeBraceExpectedAllVarsInResults()
        {
            var context = new IntellisenseProviderContext
            {
                CaretPosition = 17,
                InputText = "Sum([[Scalar]],[[)",
                DesiredResultSet = IntellisenseDesiredResultSet.EntireSet
            };

            var getResults = new DefaultIntellisenseProvider().GetIntellisenseResults(context);

            Assert.AreEqual(9, getResults.Count);
            Assert.AreEqual("[[Scalar]]", getResults[0].ToString());
            Assert.AreEqual("[[Country]]", getResults[1].ToString());
            Assert.AreEqual("[[State]]", getResults[2].ToString());
            Assert.AreEqual("[[City(", getResults[3].ToString());
            Assert.AreEqual("[[City().Name]]", getResults[4].ToString());
            Assert.AreEqual("[[City(*).Name]]", getResults[5].ToString());
            Assert.AreEqual("[[City().GeoLocation]]", getResults[6].ToString());
            Assert.AreEqual("[[City(*).GeoLocation]]", getResults[7].ToString());
            Assert.AreEqual("Invalid Expression", getResults[8].ToString());
        }
コード例 #16
0
        public void GetIntellisenseResultsWithCommaSeperatedRegionsAndNumberIndexExpectedNoResults()
        {
            var context = new IntellisenseProviderContext
            {
                CaretPosition = 19,
                InputText = "[[Scalar]],[[City(5).Name]],[[Country]]",
                DesiredResultSet = IntellisenseDesiredResultSet.Default
            };

            var getResults = new DefaultIntellisenseProvider().GetIntellisenseResults(context);

            Assert.AreEqual(0, getResults.Count);
        }
コード例 #17
0
        // ReSharper disable InconsistentNaming
        public void GetIntellisenseResults_With_Sum_AndAfterComma_Expected_AllVarsInResults()
        // ReSharper restore InconsistentNaming
        {
            var context = new IntellisenseProviderContext
            {
                CaretPosition = 17,
                InputText = "Sum([[Scalar]],[[",
                DesiredResultSet = IntellisenseDesiredResultSet.Default
            };
            var getResults = new DefaultIntellisenseProvider().GetIntellisenseResults(context);

            Assert.AreEqual(9, getResults.Count);
            Assert.AreEqual("[[Scalar]]", getResults[0].ToString());
            Assert.AreEqual("[[Country]]", getResults[1].ToString());
            Assert.AreEqual("[[State]]", getResults[2].ToString());
            Assert.AreEqual("[[City(", getResults[3].ToString());
            Assert.AreEqual("[[City().Name]]", getResults[4].ToString());
            Assert.AreEqual("[[City(*).Name]]", getResults[5].ToString());
            Assert.AreEqual("[[City().GeoLocation]]", getResults[6].ToString());
            Assert.AreEqual("[[City(*).GeoLocation]]", getResults[7].ToString());
            Assert.AreEqual("Invalid Expression", getResults[8].ToString());
        }
コード例 #18
0
        public void IntellisenseProvider_GetIntellisenseResults_WhenOpeningBracketsAndNoRecordset_ValidResults()
        {
            //------------Setup for test--------------------------
            var context = new IntellisenseProviderContext
            {
                CaretPosition = 9,
                InputText = "[[city().",
                DesiredResultSet = IntellisenseDesiredResultSet.Default,
                FilterType = enIntellisensePartType.RecordsetFields
            };

            //------------Execute Test---------------------------
            var getResults = new DefaultIntellisenseProvider().GetIntellisenseResults(context);

            //------------Assert Results-------------------------
            Assert.AreEqual(6, getResults.Count);

            Assert.AreEqual("[[City(", getResults[0].ToString());
            Assert.AreEqual("[[City().Name]]", getResults[1].ToString());
            Assert.AreEqual("[[City(*).Name]]", getResults[2].ToString());
            Assert.AreEqual("[[City().GeoLocation]]", getResults[3].ToString());
            Assert.AreEqual("[[City(*).GeoLocation]]", getResults[4].ToString());
            Assert.AreEqual("Invalid Expression", getResults[5].ToString());
        }
コード例 #19
0
        public void GetIntellisenseResultsWhereBracketOfRecordsetIsClosedAndThereIsAFieldAfterClosedBracketAndStarIndexExpectedNoResultsAndException()
        {
            var context = new IntellisenseProviderContext
            {
                CaretPosition = 9,
                InputText = "[[City(*).Name]]",
                DesiredResultSet = IntellisenseDesiredResultSet.Default
            };

            var getResults = new DefaultIntellisenseProvider().GetIntellisenseResults(context);

            Assert.AreEqual(0, getResults.Count);
        }
コード例 #20
0
        // ReSharper disable InconsistentNaming
        public void GetIntellisenseResultsWithNumberExpectedErrorInResults()
        // ReSharper restore InconsistentNaming
        {
            var context = new IntellisenseProviderContext
            {
                CaretPosition = 3,
                InputText = "[[4]]",
                DesiredResultSet = IntellisenseDesiredResultSet.Default
            };

            var getResults = new DefaultIntellisenseProvider().GetIntellisenseResults(context);

            Assert.AreEqual(1, getResults.Count);
            Assert.AreEqual("Variable name [[4]] begins with a number", getResults[0].Description);
        }
コード例 #21
0
        public void GetIntellisenseResultsWithAdjacentRegionsInParamaterOfInfragisticsFunctionExpectedAllVarsInResults()
        {
            var context = new IntellisenseProviderContext
            {
                CaretPosition = 27,
                InputText = "Sum([[Scalar]],[[Scalar]][[",
                DesiredResultSet =
                IntellisenseDesiredResultSet.EntireSet
            };

            var getResults = new DefaultIntellisenseProvider().GetIntellisenseResults(context);

            Assert.AreEqual(9, getResults.Count);
            Assert.AreEqual("[[Scalar]]", getResults[0].ToString());
            Assert.AreEqual("[[Country]]", getResults[1].ToString());
            Assert.AreEqual("[[State]]", getResults[2].ToString());
            Assert.AreEqual("[[City(", getResults[3].ToString());
            Assert.AreEqual("[[City().Name]]", getResults[4].ToString());
            Assert.AreEqual("[[City(*).Name]]", getResults[5].ToString());
            Assert.AreEqual("[[City().GeoLocation]]", getResults[6].ToString());
            Assert.AreEqual("[[City(*).GeoLocation]]", getResults[7].ToString());
            Assert.AreEqual("Invalid Expression", getResults[8].ToString());
        }
コード例 #22
0
        // ReSharper restore InconsistentNaming
        public void GetIntellisenseResultsWithOpenRegionAndOpenRegionStarIndexExpectedNoResults()
        {
            var context = new IntellisenseProviderContext
            {
                CaretPosition = 10,
                InputText = "[[City([[*",
                DesiredResultSet = IntellisenseDesiredResultSet.Default
            };

            var getResults = new DefaultIntellisenseProvider().GetIntellisenseResults(context);

            Assert.AreEqual(1, getResults.Count);
            Assert.AreEqual("Invalid Expression", getResults[0].ToString());
        }
コード例 #23
0
        public void GetIntellisenseResultsWhereInputTextContainsSpecialCharactersExpectedNoResultsAndException()
        {
            var context = new IntellisenseProviderContext
            {
                CaretPosition = 30,
                InputText = "!@#$%^&*()_+[]{}\\|;:'\",./?><",
                DesiredResultSet = IntellisenseDesiredResultSet.Default
            };

            var getResults = new DefaultIntellisenseProvider().GetIntellisenseResults(context);
            Assert.AreEqual(0, getResults.Count);
        }
コード例 #24
0
        public void GetIntellisenseResultsWithInRegionAndNumberIndexAndWithFieldExpectedNoResults()
        {
            var context = new IntellisenseProviderContext
            {
                CaretPosition = 9,
                InputText = "[[City(33).Name]]",
                DesiredResultSet = IntellisenseDesiredResultSet.Default
            };

            var getResults = new DefaultIntellisenseProvider().GetIntellisenseResults(context);

            Assert.AreEqual(0, getResults.Count);
        }
コード例 #25
0
        public void GetIntellisenseResultsWithClosingSquareBraceExpectedInvalidExpressionResult()
        {
            var context = new IntellisenseProviderContext
            {
                CaretPosition = 9,
                InputText = "[[scalar]",
                DesiredResultSet = IntellisenseDesiredResultSet.Default
            };

            var getResults = new DefaultIntellisenseProvider().GetIntellisenseResults(context);

            Assert.AreEqual("Invalid expression: Opening and closing brackets dont match.", getResults[0].Description);
        }
コード例 #26
0
        public void GetIntellisenseResultsWithNoRegionAndStarNumberAndWithFieldExpectedNoResults()
        {
            var context = new IntellisenseProviderContext
            {
                CaretPosition = 6,
                InputText = "City(4).Name",
                DesiredResultSet = IntellisenseDesiredResultSet.ClosestMatch
            };

            var getResults = new DefaultIntellisenseProvider().GetIntellisenseResults(context);

            Assert.AreEqual(0, getResults.Count);
        }
コード例 #27
0
        //2013.06.11: Ashley Lewis for bug 8759 - intellisense for partial field
        public void GetIntellisenseResultsWithPartialFieldAndScalarsInIndexExpectedVarInResultIndices()
        {
            var context = new IntellisenseProviderContext
            {
                CaretPosition = 22,
                InputText = "[[City([[Scalar]]).Nam",
                DesiredResultSet = IntellisenseDesiredResultSet.Default
            };

            var getResults = new DefaultIntellisenseProvider().GetIntellisenseResults(context);

            Assert.AreEqual(1, getResults.Count);
            Assert.AreEqual("[[City([[Scalar]]).Name]]", getResults[0].ToString());
        }
コード例 #28
0
        public void GetIntellisenseResultsWithOpenRegionAndAfterNumberIndexAndWithPartialFieldExpectedScalarVarInResults()
        {
            var context = new IntellisenseProviderContext
            {
                CaretPosition = 12,
                InputText = "[[City(6).Na",
                DesiredResultSet = IntellisenseDesiredResultSet.Default
            };

            var getResults = new DefaultIntellisenseProvider().GetIntellisenseResults(context);

            Assert.AreEqual(2, getResults.Count);
            Assert.AreEqual("[[City().Name]]", getResults[0].ToString());
            Assert.AreEqual("Invalid Expression", getResults[1].ToString());
        }
コード例 #29
0
        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;
        }
コード例 #30
0
        // ReSharper disable InconsistentNaming
        public void GetIntellisenseResults_With_OpenRegion_AndInRecSetIndex_AndWithField_Expected_RecSetVarInResults()
        // ReSharper restore InconsistentNaming
        {
            var context = new IntellisenseProviderContext
            {
                CaretPosition = 12,
                InputText = "[[City([[Cit).Name]]",
                DesiredResultSet = IntellisenseDesiredResultSet.Default
            };

            var getResults = new DefaultIntellisenseProvider().GetIntellisenseResults(context);

            Assert.AreEqual(6, getResults.Count);
            Assert.AreEqual("[[City(", getResults[0].ToString());
            Assert.AreEqual("[[City().Name]]", getResults[1].ToString());
            Assert.AreEqual("[[City(*).Name]]", getResults[2].ToString());
            Assert.AreEqual("[[City().GeoLocation]]", getResults[3].ToString());
            Assert.AreEqual("[[City(*).GeoLocation]]", getResults[4].ToString());
            Assert.AreEqual("Invalid Expression", getResults[5].ToString());

        }