-
-
Notifications
You must be signed in to change notification settings - Fork 713
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
LSP: Support document symbols #3275
Conversation
- Add label location to relevant types - Modify parser to attach label locations - Use label locations for selection_range - Ensure 'range' spans the whole symbol, including type constructors and function bodies
By the way, let me know if I should have used |
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.
Wonderful! Thank you! I've left some notes inline
- Had to add a small workaround for 'put_doc' at ast.rs; hope there is a better solution
don't compare the source spans, only the labels
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.
Lovely work! I've left a few notes inline, and we'll need tests for the document symbols part.
I'll look into adding some tests soon :) |
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.
Lovely work!! Could you add some tests and also add that comment to each of the #[allow
attributes please 🙏
Sure, I'll do it soon! |
Some initial notes from tests:
Other stuff before undrafting:
|
now the '(pub) const' keywords are included
now we can have arg constructor spans starting at docs
@lpil There we go, had to make several changes when rebasing on main and upon adding tests, but I think it should be fine now. Feel free to take a look :) |
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.
Thank you. I've left some more notes inline.
I think something has gone awry with the rebase, there's conflicts which mean I cannot rebase this branch into main.
That's probably due to merge commits; you'll have to squash and merge instead. (I tried to manually squash locally, but it's a bit difficult at this point :p) |
There we go! The CI is failing as it seems you've added an explicit check against merge commits, but other than that it's fine. I believe I owe a bit of an explanation: The reason I've used merge commits to keep the branch up-to-date with Gleam's With that said, it may of course be preferable to be able to rebase the PR to Regarding this PR, you should be able to squash and merge as needed, given the above. Let me know if you face any problems or have any concerns. |
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.
Thank you!!!!
Fixes #3252
The main implementation is mostly done. All that is left is:
selection_range
, I imagine that the correct range would be one pointing to the identifier for each symbol (e.g. a range aroundName
inpub type Name
); right now I just duplicated the full symbol's range. I will look into this soon (draft in the meantime).It may also be desirable to write the full function signature alongside function symbols instead of just their types (at least, that's how
rust-analyzer
does it), but, in principle, the type has been working fine for an MVP. We could change this later if needed.By the way, the
#[allow(deprecated)]
are becauseDocumentSymbol
contains a deprecated field, but we have to specify it anyway to construct it.Showcase
The source code below:
produces the following outline on VSCode: