Exemplo n.º 1
0
        public TextDocumentAttributes GetTextDocumentAttributes(DocumentUri uri)
        {
            var document = _workspace.GetDocument(uri);

            return(new TextDocumentAttributes(
                       uri,
                       Helpers.ToLspLanguage(document.Language)));
        }
Exemplo n.º 2
0
        public Task <Unit> Handle(DidChangeTextDocumentParams notification, CancellationToken cancellationToken)
        {
            var document = _workspace.GetDocument(notification.TextDocument.Uri);

            if (document == null)
            {
                return(Unit.Task);
            }

            _workspace.UpdateDocument(
                document,
                notification.ContentChanges.Select(x =>
                                                   Helpers.ToTextChange(
                                                       document,
                                                       x.Range,
                                                       x.Text)));

            return(Unit.Task);
        }
        public async Task <DocumentSymbolInformationContainer> Handle(DocumentSymbolParams request, CancellationToken token)
        {
            var document = _workspace.GetDocument(request.TextDocument.Uri);

            var searchService = _workspace.Services.GetService <INavigateToSearchService>();

            var symbols = ImmutableArray.CreateBuilder <DocumentSymbolInformation>();

            foreach (var logicalDocument in document.LogicalDocuments)
            {
                await Helpers.FindSymbolsInDocument(searchService, logicalDocument, string.Empty, token, symbols);
            }

            return(new DocumentSymbolInformationContainer(symbols));
        }
Exemplo n.º 4
0
        public async Task <SymbolInformationOrDocumentSymbolContainer> Handle(DocumentSymbolParams request, CancellationToken token)
        {
            var document = _workspace.GetDocument(request.TextDocument.Uri);

            var searchService = _workspace.Services.GetService <INavigateToSearchService>();

            var symbols = ImmutableArray.CreateBuilder <SymbolInformation>();

            await Helpers.FindSymbolsInDocument(searchService, document, string.Empty, token, symbols);

            var symbolsResult = ImmutableArray.CreateRange(
                symbols.ToImmutable(),
                x => new SymbolInformationOrDocumentSymbol(x));

            return(new SymbolInformationOrDocumentSymbolContainer(symbolsResult));
        }