ionide / FsAutoComplete

F# language server using Language Server Protocol
Other
389 stars 151 forks source link

Refactor AdaptiveServerState.forceFindOpenFileOrRead #1208

Closed 1eyewonder closed 7 months ago

1eyewonder commented 7 months ago

WHAT

πŸ€–[deprecated] Generated by Copilot at 5501b05

The pull request simplifies the error handling of various functions and methods in the FsAutoComplete project by using option and asyncOption types instead of Result and ResultOrString types. This avoids unnecessary wrapping and unwrapping of results and allows returning more informative error messages. The pull request affects the files src/FsAutoComplete.Core/Commands.fs, src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs, src/FsAutoComplete/LspServers/AdaptiveServerState.fs, src/FsAutoComplete/CodeFixes.fs, src/FsAutoComplete/CodeFixes.fsi, and several files in the src/FsAutoComplete/CodeFixes folder.

πŸ€–[deprecated] Generated by Copilot at 5501b05

We're sailing on the asyncOption tide We've left the Result types behind We'll heave away and simplify the code And make the error messages more kind

πŸ“„πŸ› οΈπŸš€

WHY

This function was being used as a Result type and often times being converted to an option type. Since the function either was opened or it wasn't, I felt this refactor expresses the intent more clearly. It think it also allows the higher order functions to "think" more on what better error messages could be, rather than passing the "could not read file" up the pipeline.

HOW

πŸ€–[deprecated] Generated by Copilot at 5501b05

Note

I also updated FsToolkit.ErrorHandling to the latest version