コード例 #1
0
 public RazorCompletionResolveEndpointTest()
 {
     LSPTagHelperTooltipFactory   = Mock.Of <LSPTagHelperTooltipFactory>(MockBehavior.Strict);
     VSLSPTagHelperTooltipFactory = Mock.Of <VSLSPTagHelperTooltipFactory>(MockBehavior.Strict);
     CompletionListCache          = new CompletionListCache();
     CompletionCapability         = new VSInternalCompletionSetting()
     {
         CompletionItem = new CompletionItemSetting()
         {
             DocumentationFormat = new[] { MarkupKind.PlainText, MarkupKind.Markdown },
         }
     };
     DefaultClientCapability = new VSInternalClientCapabilities()
     {
         TextDocument = new TextDocumentClientCapabilities()
         {
             Completion = CompletionCapability,
         },
     };
     VSClientCapability = new VSInternalClientCapabilities()
     {
         TextDocument = new TextDocumentClientCapabilities()
         {
             Completion = CompletionCapability,
         },
         SupportsVisualStudioExtensions = true,
     };
 }
コード例 #2
0
        public void Convert_CommitCharactersTrue_RemovesCommitCharactersFromItems()
        {
            // Arrange
            var commitCharacters = new[] { "<" };
            var completionList   = new VSInternalCompletionList()
            {
                Items = new[]
                {
                    new VSInternalCompletionItem()
                    {
                        Label = "Test",
                        VsCommitCharacters = commitCharacters
                    }
                }
            };
            var capabilities = new VSInternalCompletionSetting()
            {
                CompletionList = new VSInternalCompletionListSetting()
                {
                    CommitCharacters = true,
                }
            };

            // Act
            var vsCompletionList = CompletionListOptimizer.Optimize(completionList, capabilities);

            // Assert
            Assert.Collection(vsCompletionList.Items, (item) => Assert.Null(item.CommitCharacters));

            Assert.Collection(vsCompletionList.CommitCharacters.Value.First, (e) => Assert.Equal("<", e));
        }
コード例 #3
0
        public void Convert_DataFalse_DoesNotTouchData()
        {
            // Arrange
            var dataObject = new JObject()
            {
                ["resultId"] = 123
            };
            var completionList = new VSInternalCompletionList()
            {
                Items = new[]
                {
                    new VSInternalCompletionItem()
                    {
                        Label = "Test",
                        Data  = dataObject,
                    }
                }
            };
            var capabilities = new VSInternalCompletionSetting()
            {
                CompletionList = new VSInternalCompletionListSetting()
                {
                    Data = false,
                }
            };

            // Act
            var vsCompletionList = CompletionListOptimizer.Optimize(completionList, capabilities);

            // Assert
            Assert.Collection(vsCompletionList.Items, item => Assert.Same(dataObject, item.Data));
            Assert.Null(vsCompletionList.Data);
        }
コード例 #4
0
        public void Convert_CommitCharactersFalse_DoesNotTouchCommitCharacters()
        {
            // Arrange
            var commitCharacters = new[] { "<" };
            var completionList   = new VSInternalCompletionList()
            {
                Items = new[]
                {
                    new VSInternalCompletionItem()
                    {
                        Label = "Test",
                        VsCommitCharacters = commitCharacters
                    }
                }
            };
            var capabilities = new VSInternalCompletionSetting()
            {
                CompletionList = new VSInternalCompletionListSetting()
                {
                    CommitCharacters = false,
                }
            };

            // Act
            var vsCompletionList = CompletionListOptimizer.Optimize(completionList, capabilities);

            // Assert
            Assert.Collection(vsCompletionList.Items, item => Assert.Equal(commitCharacters, ((VSInternalCompletionItem)item).VsCommitCharacters));
            Assert.Null(vsCompletionList.CommitCharacters);
        }
コード例 #5
0
        private static VSInternalCompletionList OptimizeData(VSInternalCompletionList completionList, VSInternalCompletionSetting completionCapability)
        {
            var completionListCapability = completionCapability.CompletionList;

            if (completionListCapability?.Data != true)
            {
                return(completionList);
            }

            completionList = PromoteDataOntoList(completionList);

            return(completionList);
        }
コード例 #6
0
        private static VSInternalCompletionList OptimizeCommitCharacters(VSInternalCompletionList completionList, VSInternalCompletionSetting completionCapability)
        {
            var completionListCapability = completionCapability.CompletionList;

            if (completionListCapability?.CommitCharacters != true)
            {
                return(completionList);
            }

            // The commit characters capability is a VS capability with how we utilize it, therefore we want to promote onto the VS list.
            completionList = PromoteVSCommonCommitCharactersOntoList(completionList);
            return(completionList);
        }