-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix-issue-5554-soundness
- Loading branch information
Showing
9 changed files
with
155 additions
and
60 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
Source/DafnyLanguageServer.Test/Completion/AtCompletionTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using Microsoft.Dafny.LanguageServer.IntegrationTest.Extensions; | ||
using OmniSharp.Extensions.LanguageServer.Protocol.Document; | ||
using OmniSharp.Extensions.LanguageServer.Protocol.Models; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.Dafny.LanguageServer.IntegrationTest.Util; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Microsoft.Dafny.LanguageServer.IntegrationTest.Completion { | ||
public class AtCompletionTest : ClientBasedLanguageServerTest { | ||
|
||
private async Task<List<CompletionItem>> RequestCompletionAsync(TextDocumentItem documentItem, Position position) { | ||
var completionList = await client.RequestCompletion( | ||
new CompletionParams { | ||
TextDocument = documentItem.Uri, | ||
Position = position | ||
}, | ||
CancellationToken | ||
).AsTask(); | ||
return completionList.OrderBy(completion => completion.Label).ToList(); | ||
} | ||
|
||
[Fact] | ||
public async Task CompleteNoAtAttributeDuringAtCall() { | ||
var source = @" | ||
method Foo() { label start: previous@(x); }".TrimStart(); | ||
var documentItem = CreateAndOpenTestDocument(source, "CompleteAtCall.dfy"); | ||
|
||
var completionList = await RequestCompletionAsync(documentItem, (0, 37)); | ||
Assert.Empty(completionList); | ||
} | ||
|
||
private static void AssertEqualToAllCompletions(List<CompletionItem> completionList) { | ||
Assert.Equal(Attributes.BuiltinAtAttributes.Count, completionList.Count); | ||
for (var i = 0; i < completionList.Count; i++) { | ||
Assert.Equal(Attributes.BuiltinAtAttributes[0].Name, completionList[0].Label); | ||
Assert.Equal(CompletionItemKind.Constructor, completionList[1].Kind); | ||
} | ||
} | ||
|
||
[Fact] | ||
public async Task CompleteAtAttributeAtBeginningOfFile() { | ||
var source = "@"; | ||
var documentItem = CreateTestDocument(source, "CompleteAt.dfy"); | ||
await client.OpenDocumentAndWaitAsync(documentItem, CancellationToken); | ||
var completionList = await RequestCompletionAsync(documentItem, (0, 1)); | ||
AssertEqualToAllCompletions(completionList); | ||
} | ||
|
||
[Fact] | ||
public async Task CompleteAtAttributeBeforeMethod() { | ||
var source = @" | ||
/* Does what is expected */ @ method Foo() { }".TrimStart(); | ||
var documentItem = CreateTestDocument(source, "CompleteAtBeforeMethod.dfy"); | ||
await client.OpenDocumentAndWaitAsync(documentItem, CancellationToken); | ||
var completionList = await RequestCompletionAsync(documentItem, (0, 29)); | ||
AssertEqualToAllCompletions(completionList); | ||
} | ||
|
||
[Fact] | ||
public async Task CompleteAtAttributeBeforeMethodAfterNewline() { | ||
var source = @" | ||
/* Does what is expected */".TrimStart() + "\n" + | ||
"@ method Foo() { }".TrimStart(); | ||
var documentItem = CreateTestDocument(source, "CompleteOnThisReturnsClassMembers.dfy"); | ||
await client.OpenDocumentAndWaitAsync(documentItem, CancellationToken); | ||
var completionList = await RequestCompletionAsync(documentItem, (1, 1)); | ||
AssertEqualToAllCompletions(completionList); | ||
} | ||
|
||
public AtCompletionTest(ITestOutputHelper output) : base(output) { | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 0 additions & 42 deletions
42
Source/DafnyLanguageServer/Workspace/DocumentTextBuffer.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters