-
Notifications
You must be signed in to change notification settings - Fork 5.4k
LSP: Fix “Go to Definition” for struct generic parameters & add token-scan guard #7198
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
base: master
Are you sure you want to change the base?
Conversation
please update title accordingly. |
please ellaborate more , what title ? |
Thanks for the PR. I'll take a look at this on Monday. The PR tilte is simply "Dev". Can you rename this to better describe the PR. Thanks. |
dn |
The title is still very generic; when one looks at merged PRs (or release notes), it's difficult to know at glance what the PR did - since you used the issue number as the title.. |
sway-lsp/src/core/session.rs
Outdated
let mut struct_token = None; | ||
let mut checked = 0; | ||
for entry in token_map.tokens_for_file(uri) { | ||
if checked > 1000 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This arbitrary limit of 1000 iterations has no justification and could break on legitimate large files - either fix the underlying O(n²) complexity or provide proper rationale for this number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR needs test cases that reproduce the original bug from issue #7025 and verify the fix works correctly. Additionally, the current approach introduces O(n²) complexity and arbitrary iteration limits that need to be addressed before merging.
summary of fix
|
Description
closes #7025.
This pull request enhances the logic for resolving "Go to Definition" in the
Session
implementation of the Sway language server.The primary change introduces additional checks to handle type parameters within struct declarations more accurately, ensuring the resolution is restricted to the relevant struct context.
Improvements to "Go to Definition" logic:
Checklist
Breaking*
orNew Feature
labels where relevant.