-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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: generate doc comments for trait functions #4665
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sdankel
commented
Jun 13, 2023
sdankel
commented
Jun 13, 2023
I'm just here for the vibes and support, go team! |
JoshuaBatty
reviewed
Jun 14, 2023
sdankel
commented
Jun 15, 2023
JoshuaBatty
approved these changes
Jun 15, 2023
tritao
approved these changes
Jun 15, 2023
kayagokalp
approved these changes
Jun 15, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
compiler: frontend
Everything to do with type checking, control flow analysis, and everything between parsing and IRgen
language server
LSP server
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Closes #4645
This PR lets the user generate doc comments for ABI methods. Previously it was working for functions and function implementations of ABI/trait, but not on the ABI/trait definition itself.
Since the output is exactly the same for FunctionDecl to TraitFn, I wanted to do this in a way where they could share the code. I ended up writing a trait called
FunctionSignature
that both types implement that exposesparameters()
andreturn_type()
. This allows me to use the same code for code actions and I suspect it will come in handy in the future.One problem was that
FunctionDecl
's return_type wasTypeArgument
whileTraitFn
had its return type asTypeId
with an additionalreturn_type_span
field. I changed it so thatTraitFn
's return_type is nowTypeArgument
and removedreturn_type_span
.I also needed to add a
span
field toTraitFn
since previously itsspan()
was returning only the span of the function name, not the whole function. From what I could see, this doesn't impact the spans of any existing errors.Testing
I added an integration test to the LSP for this scenario.
Example
Checklist
Breaking*
orNew Feature
labels where relevant.