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

Quick action to explicitly annotate a let binding parameter #10421

Closed
Tracked by #15561
cartermp opened this issue Nov 10, 2020 · 5 comments
Closed
Tracked by #15561

Quick action to explicitly annotate a let binding parameter #10421

cartermp opened this issue Nov 10, 2020 · 5 comments
Labels
Area-LangService-CodeRefactorings Suggested but not necessary code actions. Screwdrivers in VS. Feature Request
Milestone

Comments

@cartermp
Copy link
Contributor

Given code like this:

let myFunc x = x.ToString()

There should be a quick action available to convert it to this:

let myFunc (x: 'a) : string = x.ToString()

This would require some work to get the inferred types of the let-bound value(s) and each parameter if it's a function, and their ranges.

@kerams
Copy link
Contributor

kerams commented Apr 23, 2022

Where should the action pop up? With caret within the function identifier?

On a related note how are quick actions actually triggered? They don't have associated diagnostic IDs like code fixes, so does Roslyn iterate over all registered providers on every hover/caret move to see if they return anything actionable at the location?

@cartermp
Copy link
Contributor Author

This would be added as a refactoring provider here: https://github.com/dotnet/fsharp/tree/main/vsintegration/src/FSharp.Editor/Refactor

@cartermp
Copy link
Contributor Author

Refactoring Providers and quick fixes are different. The former is run periodically in the editor and whenever one is applicable it is triggered to run asynchronously. The latter are triggered based off of diagnostics.

@vzarytovskii vzarytovskii moved this to Not Planned in F# Compiler and Tooling Jun 17, 2022
@psfinaki psfinaki added Area-LangService-CodeRefactorings Suggested but not necessary code actions. Screwdrivers in VS. and removed Area-LangService-CodeFixes Code fixes associated with diagnostics labels Jun 15, 2023
@psfinaki
Copy link
Member

refactoring.mp4

So this is half-there - works for parameters but not return types. Keeping the ticket, created a separate area for this to distinguish it from code fixes.

@psfinaki
Copy link
Member

psfinaki commented Jul 5, 2023

I wonder if we want to fully annotate everything we can right away.
I'd rather have separate things for suggesting explicit types for parameters (maybe also for all of them) and explicit types for return values. As in:

  • add type annotation
  • add type annotations for all parameters
  • add return type annotation

I'll close this ticket and create new ones for 2 and 3.

@psfinaki psfinaki closed this as completed Jul 5, 2023
@github-project-automation github-project-automation bot moved this from Not Planned to Done in F# Compiler and Tooling Jul 5, 2023
@psfinaki psfinaki changed the title Quick action to explicitly annotate a let binding Quick action to explicitly annotate a let binding parameter Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-LangService-CodeRefactorings Suggested but not necessary code actions. Screwdrivers in VS. Feature Request
Projects
Archived in project
Development

No branches or pull requests

4 participants