-
Notifications
You must be signed in to change notification settings - Fork 156
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
Conversation
@@ -331,6 +331,57 @@ type FSharpParseFileResults with | |||
None | |||
| _ -> defaultTraverse expr }) | |||
) | |||
|
|||
member scope.IsTypeAnnotationGivenAtPositionPatched pos = |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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: _ []) = |
There was a problem hiding this comment.
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>] |
There was a problem hiding this comment.
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>> |
There was a problem hiding this comment.
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.
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.