FsAutoComplete icon indicating copy to clipboard operation
FsAutoComplete copied to clipboard

add code fix for wildcard _ in pattern match for fs43 on |->

Open jkone27 opened this issue 10 months ago • 4 comments

Suggest | _ -> for match mistaken with infix operator |->

add code fix for wildcard operator suggestion in pattern match for fs43, targets: https://github.com/dotnet/fsharp/issues/15748

as worked in amplifying fsharp session: https://amplifying-fsharp.github.io/sessions/2023/09/01/

WHY

the operator |-> is not defined, so this is usually just a user forgetting to complete the match

HOW

🤖 Generated by Copilot at df83900

  • Add a new code fix for adding a missing wildcard operator to a match expression (link, link)
    • Define a new module FsAutoComplete.CodeFix.AddMissingWildcardOperator in src/FsAutoComplete/CodeFixes/AddMissingWildcardOperator.fs and its signature file in src/FsAutoComplete/CodeFixes/AddMissingWildcardOperator.fsi (link, link)
    • Export a title, a function to try to find the pattern that needs the fix, and a function to apply the fix using the CodeFix type and the SyntaxVisitorBase and SyntaxTraversal utilities (link, link)
  • Register the new code fix function in the language server implementations (link, link)
    • Add the function to the list of code fixes supported by the AdaptiveFSharpLspServer type in src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs (link)
    • Add the function to the list of code fixes supported by the FSharpLspServer type in src/FsAutoComplete/LspServers/FsAutoComplete.Lsp.fs (link)
  • Add a test case for the new code fix using the test helpers (link, link)
    • Define a new test module FsAutoComplete.Tests.CodeFixTests.AddMissingWildcardOperatorTests in test/FsAutoComplete.Tests.Lsp/CodeFixTests/AddMissingWildcardOperatorTests.fs (link)
    • Check that the code fix can suggest a wildcard pattern for a missing match case in a simple example using the CodeFix and Diagnostics utilities (link)
    • Add the new test module to the list of test modules in the tests function in test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs (link)

jkone27 avatar Sep 01 '23 15:09 jkone27