Beispiel #1
0
        private static void ToDocumentSymbol(Uri fileUri, IReadOnlyScriptText text, PapyrusSymbol symbol, List <DocumentSymbolInformation> symbolInformationContainer, string containerName = null)
        {
            var symbolInformation = new DocumentSymbolInformation()
            {
                Name     = symbol.Name,
                Kind     = GetSymbolKind(symbol),
                Location = new Location()
                {
                    Uri   = fileUri,
                    Range = symbol.Definition.Range.ToRange()
                },
                ContainerName = containerName
            };

            foreach (var childSymbol in symbol.Children)
            {
                ToDocumentSymbol(fileUri, text, childSymbol, symbolInformationContainer, symbolInformation.Name);
            }

            symbolInformationContainer.Add(symbolInformation);
        }
        public void SimpleTest(string expected)
        {
            var model = new DocumentSymbolInformation()
            {
                ContainerName = "abc",
                Kind          = SymbolKind.Boolean,
                Location      = new Location()
                {
                    Range = new Range(new Position(1, 2), new Position(3, 4)),
                    Uri   = new Uri("file:///abc/123.cs")
                },
                Name = "name"
            };
            var result = Fixture.SerializeObject(model);

            result.Should().Be(expected);

            var deresult = new Serializer(ClientVersion.Lsp3).DeserializeObject <DocumentSymbolInformation>(expected);

            deresult.Should().BeEquivalentTo(model);
        }
        private static void ToDocumentSymbol(FileMemberElement node, List <DocumentSymbolInformation> symbolInformationContainer, string containerName = null)
        {
            var symbolInformation = new DocumentSymbolInformation
            {
                Name     = node.Location.Text,
                Kind     = Kinds[node.Kind],
                Location = new Location
                {
                    Uri   = Helpers.ToUri(node.Location.FileName),
                    Range = node.Location.ToRange()
                },
                ContainerName = containerName
            };

            if (node.ChildNodes != null)
            {
                foreach (var childNode in node.ChildNodes)
                {
                    ToDocumentSymbol(childNode, symbolInformationContainer, symbolInformation.Name);
                }
            }
            symbolInformationContainer.Add(symbolInformation);
        }
 public DocumentSymbolInformationOrDocumentSymbol(DocumentSymbol value)
 {
     _documentSymbol = value;
     _command        = default;
 }