Esempio n. 1
0
        public async Task <CounterExampleList> Handle(CounterExampleParams request, CancellationToken cancellationToken)
        {
            var document = await documents.GetDocumentAsync(request.TextDocument);

            if (document == null)
            {
                logger.LogWarning("counter-examples requested for unloaded document {DocumentUri}", request.TextDocument.Uri);
                return(new CounterExampleList());
            }
            return(new CounterExampleLoader(logger, document, request.CounterExampleDepth, cancellationToken).GetCounterExamples());
        }
        public async override Task <SymbolInformationOrDocumentSymbolContainer> Handle(DocumentSymbolParams request, CancellationToken cancellationToken)
        {
            var document = await documents.GetDocumentAsync(request.TextDocument);

            if (document == null)
            {
                logger.LogWarning("symbols requested for unloaded document {DocumentUri}", request.TextDocument.Uri);
                return(EmptySymbols);
            }
            var visitor = new LspSymbolGeneratingVisitor(document.SymbolTable, cancellationToken);
            var symbols = visitor.Visit(document.SymbolTable.CompilationUnit)
                          .Select(symbol => new SymbolInformationOrDocumentSymbol(symbol))
                          .ToArray();

            return(symbols);
        }
Esempio n. 3
0
        public async override Task <Hover?> Handle(HoverParams request, CancellationToken cancellationToken)
        {
            logger.LogTrace("received hover request for {Document}", request.TextDocument);
            var document = await documents.GetDocumentAsync(request.TextDocument);

            if (document == null)
            {
                logger.LogWarning("the document {Document} is not loaded", request.TextDocument);
                return(null);
            }
            if (!document.SymbolTable.TryGetSymbolAt(request.Position, out var symbol))
            {
                logger.LogDebug("no symbol was found at {Position} in {Document}", request.Position, request.TextDocument);
                return(null);
            }
            return(CreateHover(symbol, cancellationToken));
        }
        public async override Task <LocationOrLocationLinks> Handle(DefinitionParams request, CancellationToken cancellationToken)
        {
            var document = await documents.GetDocumentAsync(request.TextDocument);

            if (document == null)
            {
                logger.LogWarning("location requested for unloaded document {DocumentUri}", request.TextDocument.Uri);
                return(new LocationOrLocationLinks());
            }
            if (!document.SymbolTable.TryGetSymbolAt(request.Position, out var symbol))
            {
                logger.LogDebug("no symbol was found at {Position} in {Document}", request.Position, request.TextDocument);
                return(new LocationOrLocationLinks());
            }
            var location = GetLspLocation(document, symbol);

            if (location == null)
            {
                logger.LogDebug("failed to resolve the location of the symbol {SymbolName} at {Position} in {Document}",
                                symbol.Name, request.Position, request.TextDocument);
                return(new LocationOrLocationLinks());
            }
            return(new[] { location });
        }