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

(mostly) implement explicit type annotation codefix #807

Merged
merged 4 commits into from
Jun 25, 2021

Conversation

baronfel
Copy link
Contributor

Closes #806

Ports over most of the implementation from upstream, but currently doesn't handle function-typed parameters at all due to missing fields on the FCS data types.

@baronfel baronfel changed the title (mosty) implement explicit type annotation codefix (mostly) implement explicit type annotation codefix Jun 25, 2021
@@ -331,6 +331,57 @@ type FSharpParseFileResults with
None
| _ -> defaultTraverse expr })
)

member scope.IsTypeAnnotationGivenAtPositionPatched pos =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ported over from upstream

@@ -21,7 +21,7 @@ type SourceTextExtensions =
static member GetText(t: ISourceText, m: FSharp.Compiler.Text.Range): Result<string, string> =
let allFileRange = Range.mkRange m.FileName Pos.pos0 (t.GetLastFilePosition())
if not (Range.rangeContainsRange allFileRange m)
then Error "%A{m} is outside of the bounds of the file"
then Error $"%A{m} is outside of the bounds of the file"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix for malformed format string

@@ -397,6 +397,15 @@ module Array =
| _ when n >= xs.Length || n < 0 -> xs, [||]
| _ -> xs.[0..n-1], xs.[n..]

let partitionResults (xs: _ []) =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used in refactor of codefixes

@@ -25,6 +25,7 @@ module Types =
type GetParseResultsForFile = string<LocalPath> -> FSharp.Compiler.Text.Pos -> Async<ResultOrString<ParseAndCheckResults * string * FSharp.Compiler.Text.ISourceText>>
type GetProjectOptionsForFile = string<LocalPath> -> ResultOrString<FSharp.Compiler.SourceCodeServices.FSharpProjectOptions>

[<RequireQualifiedAccess>]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally moving to RQA on DUs to prevent conflicts

@@ -37,7 +38,7 @@ module Types =
SourceDiagnostic: Diagnostic option
Kind: FixKind }

type CodeFix = CodeActionParams -> Async<Fix list>
type CodeFix = CodeActionParams -> Async<Result<Fix list, string>>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

making this AsyncResult makes authoring codefixes nicer, IMO. we do the unification and logging in the LSP endpoint itself now.

@baronfel baronfel merged commit f0b8e01 into ionide:master Jun 25, 2021
@baronfel baronfel deleted the extract-refactor-fixes branch June 25, 2021 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port over 'add explicit type' refactoring from dotnet/fsharp
1 participant