Пример #1
0
        public async Task TestGetDocumentSymbolsAsync()
        {
            var markup =
                @"{|class:class {|classSelection:A|}
{
    {|method:void {|methodSelection:M|}()
    {
    }|}
}|}";

            using var testLspServer = CreateTestLspServer(markup, out var locations);
            var expected = new LSP.DocumentSymbol[]
            {
                CreateDocumentSymbol(
                    LSP.SymbolKind.Class,
                    "A",
                    "A",
                    locations["class"].Single(),
                    locations["classSelection"].Single()
                    )
            };

            CreateDocumentSymbol(
                LSP.SymbolKind.Method,
                "M",
                "M()",
                locations["method"].Single(),
                locations["methodSelection"].Single(),
                expected.First()
                );

            var results = await RunGetDocumentSymbolsAsync(testLspServer, true);

            AssertJsonEquals(expected, results);
        }
Пример #2
0
        public async Task TestGetDocumentSymbolsAsync()
        {
            var markup =
                @"{|class:class {|classSelection:A|}
{
    {|method:void {|methodSelection:M|}()
    {
    }|}
}|}";
            var clientCapabilities = new LSP.ClientCapabilities()
            {
                TextDocument = new LSP.TextDocumentClientCapabilities()
                {
                    DocumentSymbol = new LSP.DocumentSymbolSetting()
                    {
                        HierarchicalDocumentSymbolSupport = true
                    }
                }
            };

            using var testLspServer = await CreateTestLspServerAsync(markup, clientCapabilities);

            var expected = new LSP.DocumentSymbol[]
            {
                CreateDocumentSymbol(LSP.SymbolKind.Class, "A", "A", testLspServer.GetLocations("class").Single(), testLspServer.GetLocations("classSelection").Single())
            };

            CreateDocumentSymbol(LSP.SymbolKind.Method, "M", "M()", testLspServer.GetLocations("method").Single(), testLspServer.GetLocations("methodSelection").Single(), expected.First());

            var results = await RunGetDocumentSymbolsAsync <LSP.DocumentSymbol[]>(testLspServer);

            AssertJsonEquals(expected, results);
        }