Skip to content

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Dannynsikak
Copy link

@Dannynsikak Dannynsikak commented May 23, 2025

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:

  • Enhanced handling of type parameters: Added logic to identify and restrict type parameter lookups to the enclosing struct declaration. This ensures that type parameters are resolved only within the context of the struct they belong to.
  • Prevented performance issues: Introduced a limit of 1000 tokens when iterating over tokens in a file to avoid potential stack overflow or performance degradation in pathological cases.
  • Fallback to original behavior: Retained the original "Go to Definition" logic as a fallback for cases where the new type parameter handling does not apply.

Checklist

  • [.] I have linked to any relevant issues.
  • [.] I have commented my code, particularly in hard-to-understand areas.
  • [.] I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • [.] I have added tests that prove my fix is effective or that my feature works.
  • [.] I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • [.] I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • [.] I have requested a review from the relevant team or maintainers.

@Dannynsikak Dannynsikak requested a review from a team as a code owner May 23, 2025 10:53
@zees-dev
Copy link
Contributor

please update title accordingly.

@Dannynsikak
Copy link
Author

please update title accordingly.

please ellaborate more , what title ?

@JoshuaBatty
Copy link
Member

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.

@Dannynsikak Dannynsikak changed the title Dev issue#7025 May 25, 2025
@Dannynsikak
Copy link
Author

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

@zees-dev zees-dev changed the title issue#7025 LSP: Fix “Go to Definition” for struct generic parameters & add token-scan guard May 25, 2025
@zees-dev
Copy link
Contributor

zees-dev commented May 25, 2025

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..
I have updated it accordingly to LSP: Fix “Go to Definition” for struct generic parameters & add token-scan guard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

impl item after struct decl, confuses LSP "go to definition"
3 participants