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

Fix runnables code lens in multi-file sway projects #4984

Merged
merged 8 commits into from
Aug 23, 2023

Conversation

sdankel
Copy link
Member

@sdankel sdankel commented Aug 19, 2023

Description

Closes #4983

The issue was that we were returning all of the runnables for the workspace, rather than just the file. We were also calling get_range_from_span for every runnable at request time, which @JoshuaBatty discovered is very costly.

  • The runnables map is now mapping [file path] => [vector of runnables for that file]
  • Rather than iterating over all of the runnables in the session, we just fetch the vector of runnables indexed by the file path.
  • Runnables are now storing the range rather than the span, so we don't need to convert it at request time.
  • Added another test that expects no runnables to be returned for a file in a workspace that has runnables in other files. This test was failing before the change. Previously, the runnables test was running on test files from the e2e directory, so I copied that into the LSP fixtures.
  • Moved the code_lens logic into a capability and updated the bencher

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.

@sdankel sdankel changed the title Fix runnables code lens in multi-file projects Fix runnables code lens in multi-file sway projects Aug 19, 2023
@sdankel sdankel marked this pull request as ready for review August 19, 2023 01:06
@sdankel sdankel requested a review from a team August 19, 2023 01:06
@sdankel sdankel self-assigned this Aug 19, 2023
@JoshuaBatty JoshuaBatty added the language server LSP server label Aug 21, 2023
@JoshuaBatty
Copy link
Member

Nice optimisation! just some small nits.

@sdankel sdankel requested review from JoshuaBatty and a team August 22, 2023 23:01
@sdankel sdankel enabled auto-merge (squash) August 22, 2023 23:02
## Description
Migrates this test to use the new approach that was recently introduced.
Should fix CI errors.

## 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](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.
@JoshuaBatty JoshuaBatty requested review from a team August 23, 2023 00:46
@sdankel sdankel merged commit 6387087 into master Aug 23, 2023
30 checks passed
@sdankel sdankel deleted the sophie/4983codeLens branch August 23, 2023 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code lens showing up in weird places
3 participants