Skip to content

Commit

Permalink
Surround return type annotations with white space. Fixes fsprojects#1420
Browse files Browse the repository at this point in the history
.
  • Loading branch information
nojaf committed Feb 5, 2021
1 parent 8a2b9b3 commit 0f7209b
Show file tree
Hide file tree
Showing 26 changed files with 251 additions and 229 deletions.
4 changes: 2 additions & 2 deletions src/Fantomas.Tests/AppTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ let ``should not split parameters over multiple lines when they do not exceed pa
"""
module Caching =
type MainCache() =
member __.RetrieveLastCompoundBalance (address: PublicAddress) (currency: Currency): NotFresh<decimal> =
member __.RetrieveLastCompoundBalance (address: PublicAddress) (currency: Currency) : NotFresh<decimal> =
lock
cacheFiles.CachedNetworkData
(fun _ ->
Expand Down Expand Up @@ -252,7 +252,7 @@ let ``should not split single parameter over multiple lines when it does not exc
"""
module Caching =
type MainCache() =
member __.RetrieveLastCompoundBalance (address: PublicAddress) (currency: Currency): NotFresh<decimal> =
member __.RetrieveLastCompoundBalance (address: PublicAddress) (currency: Currency) : NotFresh<decimal> =
lock
cacheFiles.CachedNetworkData
(fun _ ->
Expand Down
14 changes: 7 additions & 7 deletions src/Fantomas.Tests/AttributeTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,16 @@ let e2e value =
#if DEBUG
[<Emit("console.log('%c' + $1, 'color: ' + $0)")>]
let printInColor (color: string) (msg: string): unit = jsNative
let printInColor (color: string) (msg: string) : unit = jsNative
[<Emit("console.log('%c' + $1, $0)")>]
let printInStyle (style: string) (msg): unit = jsNative
let printInStyle (style: string) (msg) : unit = jsNative
[<Emit("console.info($0)")>]
let printModel model: unit = jsNative
let printModel model : unit = jsNative
[<Emit("console.trace()")>]
let printStackTrace (): unit = jsNative
let printStackTrace () : unit = jsNative
#endif
let e2e value = Props.Data("e2e", value)
Expand Down Expand Up @@ -427,15 +427,15 @@ let ``should preserve single return type attribute`` () =
formatSourceString false """let f x : [<return: Attribute>] int = x""" config
|> should
equal
"""let f x: [<return: Attribute>] int = x
"""let f x : [<return: Attribute>] int = x
"""

[<Test>]
let ``should preserve multiple return type attributes`` () =
formatSourceString false """let f x : [<return: AttributeOne;AttributeTwo;AttributeThree("foo")>] int = x""" config
|> should
equal
"""let f x: [<return: AttributeOne; AttributeTwo; AttributeThree("foo")>] int = x
"""let f x : [<return: AttributeOne; AttributeTwo; AttributeThree("foo")>] int = x
"""

[<Test>]
Expand Down Expand Up @@ -688,7 +688,7 @@ type RoleAdminImportController(akkaService: AkkaService) =
ProducesResponseType(typeof<bool>, 200);
ProducesResponseType(404);
Authorize(AuthorizationScopePolicies.Read)>]
member _.ListJobs(): Task<UserCmdResponseMsg> =
member _.ListJobs() : Task<UserCmdResponseMsg> =
task {
return!
akkaService.ImporterSystem.ApiMaster
Expand Down
58 changes: 29 additions & 29 deletions src/Fantomas.Tests/ClassTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ module Heap
type Heap<'T when 'T: comparison> =
class
new: capacity: int -> Heap<'T>
member Clear: unit -> unit
member ExtractMin: unit -> 'T
member Insert: k: 'T -> unit
member IsEmpty: unit -> bool
member PeekMin: unit -> 'T
override ToString: unit -> string
member Count: int
new : capacity: int -> Heap<'T>
member Clear : unit -> unit
member ExtractMin : unit -> 'T
member Insert : k: 'T -> unit
member IsEmpty : unit -> bool
member PeekMin : unit -> 'T
override ToString : unit -> string
member Count : int
end
"""

Expand All @@ -65,19 +65,19 @@ type Class7<'T when 'T : (new : unit -> 'T)>() =
|> should
equal
"""
type Class4<'T when 'T: (static member staticMethod1: unit -> 'T)> =
type Class4<'T when 'T: (static member staticMethod1 : unit -> 'T)> =
class
end
type Class5<'T when 'T: (member Method1: 'T -> int)> =
type Class5<'T when 'T: (member Method1 : 'T -> int)> =
class
end
type Class6<'T when 'T: (member Property1: int)> =
type Class6<'T when 'T: (member Property1 : int)> =
class
end
type Class7<'T when 'T: (new: unit -> 'T)>() =
type Class7<'T when 'T: (new : unit -> 'T)>() =
member val Field = new 'T()
"""

Expand Down Expand Up @@ -124,15 +124,15 @@ type Shape2D(x0: float, y0: float) =
with get () = y
and set yval = y <- yval
abstract Area: float
abstract Perimeter: float
abstract Name: string
abstract Area : float
abstract Perimeter : float
abstract Name : string
member this.Move dx dy =
x <- x + dx
y <- y + dy
abstract member Rotate: float -> unit
abstract member Rotate : float -> unit
default this.Rotate(angle) = rotAngle <- rotAngle + angle
"""

Expand All @@ -156,13 +156,13 @@ type A =
equal
"""
type A =
abstract B: ?p1: (float * int) -> unit
abstract C: ?p1: float * int -> unit
abstract D: ?p1: (int -> int) -> unit
abstract E: ?p1: float -> unit
abstract F: ?p1: float * ?p2: float -> unit
abstract G: p1: float * ?p2: float -> unit
abstract H: float * ?p2: float -> unit
abstract B : ?p1: (float * int) -> unit
abstract C : ?p1: float * int -> unit
abstract D : ?p1: (int -> int) -> unit
abstract E : ?p1: float -> unit
abstract F : ?p1: float * ?p2: float -> unit
abstract G : p1: float * ?p2: float -> unit
abstract H : float * ?p2: float -> unit
"""

[<Test>]
Expand Down Expand Up @@ -265,7 +265,7 @@ and File(filename: string, containingFolder: Folder) =
"""
type Folder(pathIn: string) =
let path = pathIn
let filenameArray: string array = System.IO.Directory.GetFiles(path)
let filenameArray : string array = System.IO.Directory.GetFiles(path)
member this.FileArray = Array.map (fun elem -> new File(elem, this)) filenameArray
and File(filename: string, containingFolder: Folder) =
Expand Down Expand Up @@ -615,9 +615,9 @@ let ``no extra new line before abstract member with attribute, 586`` () =
type A =
[<EmitConstructor>]
abstract Create: Unit -> A
abstract Create : Unit -> A
abstract b: Unit -> Unit
abstract b : Unit -> Unit
"""

[<Test>]
Expand All @@ -627,10 +627,10 @@ let ``no extra new line between abstract members with attribute, 586`` () =
type A =
[<Emit("a")>]
abstract a: Unit -> string
abstract a : Unit -> string
[<Emit("b")>]
abstract b: Unit -> string
abstract b : Unit -> string
"""

[<Test>]
Expand Down Expand Up @@ -780,7 +780,7 @@ type Foo =
module Example
type Foo =
abstract member bar: int
abstract member bar : int
"""

[<Test>]
Expand Down
14 changes: 7 additions & 7 deletions src/Fantomas.Tests/CommentTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ let print_30_permut() =
let print_30_permut () =
/// declare and initialize
let permutation: int array =
let permutation : int array =
Array.init
n
(fun i ->
Expand Down Expand Up @@ -79,7 +79,7 @@ let print_30_permut() =
let print_30_permut () =
/// declare and initialize
let permutation: int array =
let permutation : int array =
Array.init
n
(fun (i, j) ->
Expand Down Expand Up @@ -1067,12 +1067,12 @@ type IExports =
"""
[<AllowNullLiteral>]
type IExports =
abstract DataSet: DataSetStatic
abstract DataView: DataViewStatic
abstract Graph2d: Graph2dStatic
abstract Timeline: TimelineStatic
abstract DataSet : DataSetStatic
abstract DataView : DataViewStatic
abstract Graph2d : Graph2dStatic
abstract Timeline : TimelineStatic
// abstract Timeline: TimelineStaticStatic
abstract Network: NetworkStatic
abstract Network : NetworkStatic

// type [<AllowNullLiteral>] MomentConstructor1 =
// [<Emit "$0($1...)">] abstract Invoke: ?inp: MomentInput * ?format: MomentFormatSpecification * ?strict: bool -> Moment
Expand Down
16 changes: 8 additions & 8 deletions src/Fantomas.Tests/CompilerDirectivesTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ type FunctionComponent =
/// Creates a lazy React component from a function in another file
/// ATTENTION: Requires fable-compiler 2.3, pass the external reference
/// directly to the argument position (avoid pipes)
static member inline Lazy(f: 'Props -> ReactElement, fallback: ReactElement): LazyFunctionComponent<'Props> =
static member inline Lazy(f: 'Props -> ReactElement, fallback: ReactElement) : LazyFunctionComponent<'Props> =
#if FABLE_COMPILER
let elemType =
ReactBindings.React.``lazy``
Expand Down Expand Up @@ -787,7 +787,7 @@ type FunctionComponent =
/// Creates a lazy React component from a function in another file
/// ATTENTION: Requires fable-compiler 2.3, pass the external reference
/// directly to the argument position (avoid pipes)
static member inline Lazy(f: 'Props -> ReactElement, fallback: ReactElement): LazyFunctionComponent<'Props> =
static member inline Lazy(f: 'Props -> ReactElement, fallback: ReactElement) : LazyFunctionComponent<'Props> =
#if FABLE_COMPILER
Expand Down Expand Up @@ -858,7 +858,7 @@ type FunctionComponent =
/// Creates a lazy React component from a function in another file
/// ATTENTION: Requires fable-compiler 2.3, pass the external reference
/// directly to the argument position (avoid pipes)
static member inline Lazy(f: 'Props -> ReactElement, fallback: ReactElement): LazyFunctionComponent<'Props> =
static member inline Lazy(f: 'Props -> ReactElement, fallback: ReactElement) : LazyFunctionComponent<'Props> =
#if FABLE_COMPILER
let elemType =
ReactBindings.React.``lazy``
Expand Down Expand Up @@ -905,11 +905,11 @@ let ``module with nested directives`` () =
#else
[<Import("*", "react-dom")>]
#endif
let ReactDom: IReactDom = jsNative
let ReactDom : IReactDom = jsNative
#if !FABLE_REPL_LIB
[<Import("default", "react-dom/server")>]
let ReactDomServer: IReactDomServer = jsNative
let ReactDomServer : IReactDomServer = jsNative
#endif
"""

Expand Down Expand Up @@ -938,11 +938,11 @@ let ``module with nested directives, no defines`` () =
#else
[<Import("*", "react-dom")>]
#endif
let ReactDom: IReactDom = jsNative
let ReactDom : IReactDom = jsNative
#if !FABLE_REPL_LIB
[<Import("default", "react-dom/server")>]
let ReactDomServer: IReactDomServer = jsNative
let ReactDomServer : IReactDomServer = jsNative
#endif
"""

Expand Down Expand Up @@ -971,7 +971,7 @@ let ``module with nested directives, FABLE_REPL_LIB`` () =
#else
#endif
let ReactDom: IReactDom = jsNative
let ReactDom : IReactDom = jsNative
#if !FABLE_REPL_LIB
Expand Down
4 changes: 2 additions & 2 deletions src/Fantomas.Tests/ComputationExpressionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1931,7 +1931,7 @@ let create: Highlighter =
|> should
equal
"""
let create: Highlighter =
let create : Highlighter =
fun searchTerm ->
let regex = searchTerm |> SearchTerm.toRegex
Expand Down Expand Up @@ -2023,7 +2023,7 @@ let result = ResultBuilder()
let run r1 r2 r3 =
// And here is our applicative!
let res1: Result<int, string> =
let res1 : Result<int, string> =
result {
let! a = r1
and! b = r2
Expand Down
2 changes: 1 addition & 1 deletion src/Fantomas.Tests/ControlStructureTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ let foldi (folder: 'State -> int -> 'T -> 'State) (state: 'State) (array: 'T [])
let folder =
OptimizedClosures.FSharpFunc<_, _, _, _>.Adapt folder
let mutable state: 'State = state
let mutable state : 'State = state
let len = array.Length
for i = 0 to len - 1 do
Expand Down
2 changes: 1 addition & 1 deletion src/Fantomas.Tests/DisableElmishTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ open ASTViewer.Shared
open FantomasTools.Client.ASTViewer.Model
open Thoth.Json
let encodeUrlModel code model: JsonValue =
let encodeUrlModel code model : JsonValue =
Encode.object
[ "defines", Encode.string model.Defines
"isFsi", Encode.bool model.IsFsi
Expand Down
6 changes: 3 additions & 3 deletions src/Fantomas.Tests/FormatAstTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ type Foo =
equal
"""[<AbstractClass>]
type Foo =
abstract foo: int
abstract foo : int
override __.foo = 1"""

[<Test>]
Expand All @@ -106,7 +106,7 @@ type Foo =
equal
"""[<AbstractClass>]
type Foo =
abstract foo: int
abstract foo : int
default __.foo = 1"""

[<Test>]
Expand All @@ -122,7 +122,7 @@ type Foo =
equal
"""[<AbstractClass>]
type Foo =
abstract foo: int
abstract foo : int
override __.foo = 1"""

[<Test>]
Expand Down
Loading

0 comments on commit 0f7209b

Please sign in to comment.