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

Improve code navigation for unreferenced declaration #5483

Merged

Conversation

keyboardDrummer
Copy link
Member

Description

  • Renamed IHasUsages to IHasReferences, to be more in line with LSP naming
  • Renamed IDeclarationOrUsage to IHasNavigationToken, and its member NameToken to NavigationToken
  • Respect the request.Context.IncludeDeclaration value of the LSP references request
  • Enable renaming declarations that were not referred to

How has this been tested?

  • Added tests for renaming and finding references on a declaration that is not referred to

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@keyboardDrummer keyboardDrummer enabled auto-merge (squash) May 23, 2024 12:37
@keyboardDrummer keyboardDrummer changed the title Unreferenced declaration Improve code navigation for unreferenced declaration May 23, 2024
Copy link
Member

@atomb atomb left a comment

Choose a reason for hiding this comment

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

I think this looks good. There's one comment that should probably be either removed or addressed, but I don't think that's worth blocking the merge over. I'm happy to re-approve if you do make changes related to that.

@@ -1,10 +1,11 @@
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little sad to have the DafnyCore package depend on LSP-specific stuff, but I think the tradeoff is probably worth it.

Copy link
Member

Choose a reason for hiding this comment

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

Looking more closely, I see that isn't a new dependency, so it's even more on the side of being worth it.

Copy link
Member Author

@keyboardDrummer keyboardDrummer May 29, 2024

Choose a reason for hiding this comment

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

I think it's to be expected that a compiler will have a public interface so it can be used as a library, and LSP happens to already contain many types that are useful for this interface, such as Position and Range, and used in this file, SymbolKind. I've made this PR to reduce what's in scope from DafnyCore: #5502

@@ -197,6 +198,11 @@ public TypeParameter(RangeToken tok, Name name, int positionalIndex, ParentType
}
}

public override SymbolKind? Kind => SymbolKind.TypeParameter;
public override string GetDescription(DafnyOptions options) {
return null; // TODO test the effect of this
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure how to interpret this comment. Have you tested calling GetDescription on a TypeParameter?

@keyboardDrummer keyboardDrummer merged commit 20843c9 into dafny-lang:master May 31, 2024
21 checks passed
@keyboardDrummer keyboardDrummer deleted the unreferencedDeclaration branch May 31, 2024 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants