public async Task<DafnyDocument> LoadDocumentAsync(TextDocumentItem textDocument, CancellationToken cancellationToken) {
   var dafnyDocument = await _documentLoader.LoadAsync(textDocument, VerifyOnLoad, cancellationToken);
   var databaseDocument = _documents.AddOrUpdate(textDocument.Uri, dafnyDocument, (uri, old) => dafnyDocument.Version > old.Version ? dafnyDocument : old);
   if (databaseDocument != dafnyDocument) {
     _logger.LogDebug("a newer version of {} was already loaded", textDocument.Uri);
   }
   return databaseDocument;
 }
Esempio n. 2
0
        public async Task <DafnyDocument> ApplyChangesAsync(DafnyDocument oldDocument, DidChangeTextDocumentParams documentChange, CancellationToken cancellationToken)
        {
            var changeProcessor = new ChangeProcessor(_logger, oldDocument, documentChange.ContentChanges, cancellationToken);
            var mergedItem      = new TextDocumentItem {
                LanguageId = oldDocument.Text.LanguageId,
                Uri        = oldDocument.Uri,
                Version    = documentChange.TextDocument.Version,
                Text       = changeProcessor.MigrateText()
            };
            var loadedDocument = await _documentLoader.LoadAsync(mergedItem, Verify, cancellationToken);

            if (!loadedDocument.SymbolTable.Resolved)
            {
                return(new DafnyDocument(
                           loadedDocument.Text,
                           loadedDocument.Errors,
                           loadedDocument.Program,
                           changeProcessor.MigrateSymbolTable(),
                           // TODO migrate counterexamples?
                           null
                           ));
            }
            return(loadedDocument);
        }