Skip to content

Commit

Permalink
Improve document symbol hierarchy to match rust-analyzer layout (#6678)
Browse files Browse the repository at this point in the history
## Description
Changes document symbols to provide a richer code outline view with
nested hierarchies and type information, similar to rust-analyzer's
implementation. This improves code navigation by showing relationships
between elements (e.g., structs with their fields, functions with their
variables) and includes type annotations for better understanding.

Key improvements:
- Nested symbol hierarchy instead of flat list
- Type information in symbol details
- Function signatures with parameter/return types
- Proper parent-child relationships for all code elements
- Better outline view organization

<img width="287" alt="Screenshot 2024-11-26 at 2 25 17 PM"
src="https://github.com/user-attachments/assets/aaf10eaf-90c6-40ee-9bb5-6a9a12901d36">

Note: the performance impact is due to the `get_range_from_span`
function which can't avoid calling. 19ms is still reasonable.

closes #6100

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] 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).
- [x] I have requested a review from the relevant team or maintainers.
  • Loading branch information
JoshuaBatty authored Nov 29, 2024
1 parent 33d3674 commit 2bc469a
Show file tree
Hide file tree
Showing 6 changed files with 586 additions and 67 deletions.
4 changes: 2 additions & 2 deletions sway-lsp/benches/lsp_benchmarks/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ fn benchmarks(c: &mut Criterion) {
c.bench_function("document_symbol", |b| {
b.iter(|| {
session
.symbol_information(&uri)
.map(DocumentSymbolResponse::Flat)
.document_symbols(&uri)
.map(DocumentSymbolResponse::Nested)
})
});

Expand Down
Loading

0 comments on commit 2bc469a

Please sign in to comment.