Skip to content

Fix bug in code navigation for datatype updates - #5986

Merged
keyboardDrummer merged 9 commits into
dafny-lang:masterfrom
keyboardDrummer:codeNavigationRefactoring
Dec 17, 2024
Merged

keyboardDrummer merged 9 commits into
dafny-lang:masterfrom
keyboardDrummer:codeNavigationRefactoring

Conversation

@keyboardDrummer

@keyboardDrummer keyboardDrummer commented Dec 17, 2024 •

Copy link
Copy Markdown
Member

What was changed?

  • Fix code navigation for AST nodes with multiple reference, such as datatype updates.

How has this been tested?

  • Added LSP test

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

@keyboardDrummer
keyboardDrummer marked this pull request as ready for review December 17, 2024 12:52
@keyboardDrummer
keyboardDrummer enabled auto-merge (squash) December 17, 2024 12:52
@keyboardDrummer keyboardDrummer changed the title Enable better positions for references Fix bug in code navigation for datatype updates Dec 17, 2024
MikaelMayer
MikaelMayer previously approved these changes Dec 17, 2024

@MikaelMayer MikaelMayer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Incremental but useful enhancement for better navigation. Names seem more useful for maintainability. A non-blocking suggestion on code that hasn't changed.

.Select(node => node is ISymbol ? node : ReferenceToNode.GetValueOrDefault(node))
.Where(n => n.ToLspRange().Intersects(character))
.Select(node => Declarations.TryGetValue(node, out var declaration)
? declaration : ReferenceToNode.GetValueOrDefault(node))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since this code assumes there could be many references at the same position, would it make sense to sort them by smaller length before taking the first one?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Generally this many references at the same location occurs because of AST nodes being copied and not being properly wrapped so they don't show up as copied, so the involved ranges are exactly the same.

@keyboardDrummer keyboardDrummer added the run-integration-tests Forces running the CI for integration tests even if the deep tests fail label Dec 17, 2024
@keyboardDrummer
keyboardDrummer merged commit e2d820f into dafny-lang:master Dec 17, 2024
@keyboardDrummer
keyboardDrummer deleted the codeNavigationRefactoring branch December 17, 2024 17:52
@keyboardDrummer
keyboardDrummer restored the codeNavigationRefactoring branch December 17, 2024 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-integration-tests Forces running the CI for integration tests even if the deep tests fail

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants