Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: LSP rename support #4365

Merged
merged 22 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Source/DafnyLanguageServer.Test/Refactoring/RenameTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public async Task ImplicitProjectFails() {
const i := 0
".TrimStart();

await SetUp(null);
var documentItem = await CreateAndOpenTestDocument(source);
await Assert.ThrowsAnyAsync<Exception>(() => RequestRename(documentItem, new Position(0, 6), "j"));
}
Expand All @@ -32,6 +31,14 @@ public async Task InvalidNewNameIsNoOp() {
Assert.Null(workspaceEdit);
}

[Fact]
public async Task RenameNonSymbolFails() {
var tempDir = await SetUpProjectFile();
var documentItem = await CreateAndOpenTestDocument("module Foo {}", Path.Combine(tempDir, "tmp.dfy"));
var workspaceEdit = await RequestRename(documentItem, new Position(0, 6), "space");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you do a PrepareRename call here? Can that one fail and succeed?

Assert.Null(workspaceEdit);
}

[Fact]
public async Task RenameDeclarationRenamesUsages() {
var source = @"
Expand All @@ -41,7 +48,6 @@ method M() {
}
".TrimStart();

await SetUp(null);
var tempDir = await SetUpProjectFile();
await AssertRangesRenamed(source, tempDir, "foobar");
}
Expand All @@ -53,7 +59,6 @@ public async Task RenameUsageRenamesDeclaration() {
method U() { [>><foobar<](); }
".TrimStart();

await SetUp(null);
var tempDir = await SetUpProjectFile();
await AssertRangesRenamed(source, tempDir, "M");
}
Expand All @@ -67,7 +72,6 @@ module C { import [>><A<] }
module D { import [>A<] }
".TrimStart();

await SetUp(null);
var tempDir = await SetUpProjectFile();
await AssertRangesRenamed(source, tempDir, "AAA");
}
Expand All @@ -86,7 +90,6 @@ method M(c: A.[>C<]) {}
}
".TrimStart();

await SetUp(null);
var tempDir = await SetUpProjectFile();
await AssertRangesRenamed(new[] { sourceA, sourceB }, tempDir, "CCC");
}
Expand All @@ -100,7 +103,6 @@ abstract module [>A<] {}
abstract module B { import [>><A<] }
".TrimStart();

await SetUp(null);
var tempDir = await SetUpProjectFile();
await AssertRangesRenamed(new[] { sourceA, sourceB }, tempDir, "AAA");
}
Expand Down
2 changes: 2 additions & 0 deletions docs/dev/news/4365.feat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add support for Rename LSP request
- Support requires enabling project mode and defining a Dafny project file