Beispiel #1
0
        internal async Task <NavigableSymbol[]> GetDefinitionLocationsAsync(SnapshotSpan span, CancellationToken cancellationToken)
        {
            var service = _serviceProvider.GetService(typeof(PythonToolsService)) as PythonToolsService;

            if (service != null && service.GetLanguageClient() != null)
            {
                var result = await service.GetLanguageClient().InvokeTextDocumentDefinitionAsync(
                    new LSP.TextDocumentPositionParams {
                    TextDocument = new LSP.TextDocumentIdentifier {
                        Uri = new System.Uri(_buffer.GetFilePath())
                    },
                    Position = span.Start.GetPosition()
                },
                    cancellationToken);

                if (result != null)
                {
                    if (result is JToken token)
                    {
                        var array     = ResultConverter.ConvertResult(token);
                        var locations = array as LSP.Location[];
                        if (locations != null)
                        {
                            return(locations.OrderBy(l => l.Range.Start.Line).Select(l => {
                                return new NavigableSymbol(_serviceProvider, span.GetText(), l, span);
                            }).ToArray());
                        }
                    }
                }
            }

            return(null);
        }