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

LSP: generate doc comments for trait functions #4665

Merged
merged 5 commits into from
Jun 15, 2023

Conversation

sdankel
Copy link
Member

@sdankel sdankel commented Jun 13, 2023

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 exposes parameters() and return_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 was TypeArgument while TraitFn had its return type as TypeId with an additional return_type_span field. I changed it so that TraitFn's return_type is now TypeArgument and removed return_type_span.

I also needed to add a span field to TraitFn since previously its span() 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

Jun-13-2023 14-40-21

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 marked this pull request as ready for review June 13, 2023 22:01
@sdankel sdankel requested review from a team June 13, 2023 22:01
@Braqzen
Copy link
Contributor

Braqzen commented Jun 13, 2023

I'm just here for the vibes and support, go team!

@JoshuaBatty JoshuaBatty added language server LSP server compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen labels Jun 14, 2023
@JoshuaBatty JoshuaBatty requested review from a team June 14, 2023 23:43
@sdankel sdankel enabled auto-merge (squash) June 15, 2023 01:33
@JoshuaBatty JoshuaBatty requested review from a team June 15, 2023 04:31
@sdankel sdankel merged commit 38a2b55 into master Jun 15, 2023
28 checks passed
@sdankel sdankel deleted the sophie/doc-comments-traitfn branch June 15, 2023 17:30
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code action to generate docs for ABI methods
5 participants