public override Task <LocationOrLocationLinks> Handle(DefinitionParams request, CancellationToken cancellationToken)
        {
            DafnyDocument?document;

            if (!_documents.TryGetDocument(request.TextDocument, out document))
            {
                _logger.LogWarning("location requested for unloaded document {}", request.TextDocument.Uri);
                return(Task.FromResult(new LocationOrLocationLinks()));
            }
            ILocalizableSymbol?symbol;

            if (!document.SymbolTable.TryGetSymbolAt(request.Position, out symbol))
            {
                _logger.LogDebug("no symbol was found at {} in {}", request.Position, request.TextDocument);
                return(Task.FromResult(new LocationOrLocationLinks()));
            }
            var location = GetLspLocation(document, symbol);

            if (!location.HasValue)
            {
                _logger.LogDebug("failed to resolve the location of the symbol {} at {} in {}", symbol.Name, request.Position, request.TextDocument);
                return(Task.FromResult(new LocationOrLocationLinks()));
            }
            return(Task.FromResult <LocationOrLocationLinks>(new[] { location.Value }));
        }
示例#2
0
        public Task <CounterExampleList> Handle(CounterExampleParams request, CancellationToken cancellationToken)
        {
            DafnyDocument?document;

            if (!_documents.TryGetDocument(request.TextDocument, out document))
            {
                _logger.LogWarning("counter-examples requested for unloaded document {DocumentUri}", request.TextDocument.Uri);
                return(Task.FromResult(new CounterExampleList()));
            }
            return(Task.FromResult(new CounterExampleLoader(_logger, document, cancellationToken).GetCounterExamples()));
        }
示例#3
0
        public override Task <SymbolInformationOrDocumentSymbolContainer> Handle(DocumentSymbolParams request, CancellationToken cancellationToken)
        {
            DafnyDocument?document;

            if (!_documents.TryGetDocument(request.TextDocument, out document))
            {
                _logger.LogWarning("symbols requested for unloaded document {}", request.TextDocument.Uri);
                return(Task.FromResult <SymbolInformationOrDocumentSymbolContainer>(_emptySymbols));
            }
            var visitor = new LspSymbolGeneratingVisitor(document.SymbolTable, cancellationToken);
            var symbols = visitor.Visit(document.SymbolTable.CompilationUnit).ToArray();

            return(Task.FromResult <SymbolInformationOrDocumentSymbolContainer>(symbols));
        }
示例#4
0
        public override Task <Hover?> Handle(HoverParams request, CancellationToken cancellationToken)
        {
            _logger.LogTrace("received hover request for {Document}", request.TextDocument);
            DafnyDocument?textDocument;

            if (!_documents.TryGetDocument(request.TextDocument, out textDocument))
            {
                _logger.LogWarning("the document {Document} is not loaded", request.TextDocument);
                return(Task.FromResult <Hover?>(null));
            }

            ILocalizableSymbol?symbol;

            if (!textDocument.SymbolTable.TryGetSymbolAt(request.Position, out symbol))
            {
                _logger.LogDebug("no symbol was found at {Position} in {Document}", request.Position, request.TextDocument);
                return(Task.FromResult <Hover?>(null));
            }
            return(Task.FromResult <Hover?>(CreateHover(symbol, cancellationToken)));
        }