Skip to content

Commit

Permalink
* refactor(AddExplicitReturnType.fs): remove unused CancellationToken…
Browse files Browse the repository at this point in the history
… and reformat code

* feat(AddExplicitReturnTypeTests.fs): add new test cases and dependencies for AddExplicitReturnType
  • Loading branch information
SebastianAtWork committed Nov 20, 2023
1 parent a4a837a commit aa88e55
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ type internal AddExplicitReturnType [<ImportingConstructor>] () =
| _ -> None

override _.ComputeRefactoringsAsync context =
let ct = context.CancellationToken

cancellableTask {
let document = context.Document
let position = context.Span.Start
Expand All @@ -93,7 +91,8 @@ type internal AddExplicitReturnType [<ImportingConstructor>] () =
let! lexerSymbol =
document.TryFindFSharpLexerSymbolAsync(position, SymbolLookupKind.Greedy, false, false, nameof (AddExplicitReturnType))

let! (parseFileResults, checkFileResults) = document.GetFSharpParseAndCheckResultsAsync(nameof (AddExplicitReturnType))
let! (parseFileResults, checkFileResults) =
document.GetFSharpParseAndCheckResultsAsync(nameof (AddExplicitReturnType))

let symbolUseOpt =
lexerSymbol
Expand Down Expand Up @@ -121,5 +120,4 @@ type internal AddExplicitReturnType [<ImportingConstructor>] () =
| _ -> ()

return ()
}
|> CancellableTask.startAsTask ct
} |> CancellableTask.startAsTaskWithoutCancellation
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ open Microsoft.VisualStudio.FSharp.Editor
open Xunit
open System.Linq
open FSharp.Editor.Tests.Refactors.RefactorTestFramework
open FSharp.Test.ProjectGeneration
open FSharp.Editor.Tests.Helpers
open System.Threading

[<Theory>]
[<InlineData(":int")>]
Expand Down Expand Up @@ -181,18 +184,31 @@ let ``Correctly infer custom type that is declared earlier in project`` () =

let myModule =
"""
module MyModule
type MyType = { Value: int }
"""

let code =
"""
open MyModule
open ModuleFirst
let sum a b = {Value=a+b}
"""

use context = TestContext.CreateWithCodeAndDependency code myModule
let project =
SyntheticProject.Create(
{ sourceFile "First" [] with
Source = myModule
SignatureFile = AutoGenerated
},
{ sourceFile "Second" ["First"] with
Source = code
}
)

project.SaveAndCheck() |> ignore
let solution, _ = RoslynTestHelpers.CreateSolution project
let ct = CancellationToken false
let context = new TestContext(solution, ct)

let spanStart = code.IndexOf symbolName

Expand Down

0 comments on commit aa88e55

Please sign in to comment.