Skip to content

Commit

Permalink
Merge pull request #177 from dungpa/new-fcs
Browse files Browse the repository at this point in the history
Upgrade to FCS 1.4.0.5
  • Loading branch information
dungpa committed Sep 12, 2015
2 parents 39dd512 + 3d70b8e commit 100e507
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,4 @@ pip-log.txt
.DS_Store
*.ncrunch*
TestResults.xml
*.xml
Binary file modified .paket/paket.exe
Binary file not shown.
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#### 1.11.0 - 13-09-2015
* Fix https://github.com/fsprojects/VisualFSharpPowerTools/issues/366 [#177](https://github.com/dungpa/fantomas/pull/177)
* Migrate to FCS 1.4.0.5

#### 1.10.0 - 29-08-2015
* Improve formatting of bind operator [#175](https://github.com/dungpa/fantomas/pull/175)

Expand Down
2 changes: 1 addition & 1 deletion paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ NUGET
FAKE (4.2.0)
FsCheck (2.0.7)
FSharp.Core (>= 3.1.2.5)
FSharp.Compiler.Service (1.4.0.1) - framework: >= net45
FSharp.Compiler.Service (1.4.0.5) - framework: >= net45
FSharp.Core (4.0.0.1)
FsUnit (1.3.0.1) - framework: >= net45
NUnit (>= 2.6.3)
Expand Down
6 changes: 3 additions & 3 deletions src/Fantomas.Cmd/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ open System.Reflection
[<assembly: AssemblyTitleAttribute("Fantomas")>]
[<assembly: AssemblyProductAttribute("Fantomas")>]
[<assembly: AssemblyDescriptionAttribute("Source code formatting tool for F#")>]
[<assembly: AssemblyVersionAttribute("1.10.0")>]
[<assembly: AssemblyFileVersionAttribute("1.10.0")>]
[<assembly: AssemblyVersionAttribute("1.11.0")>]
[<assembly: AssemblyFileVersionAttribute("1.11.0")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "1.10.0"
let [<Literal>] Version = "1.11.0"
26 changes: 26 additions & 0 deletions src/Fantomas.Tests/TypeDeclarationTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -748,3 +748,29 @@ type ILogger =
type ILogger =
abstract DebugFormat : format:String * [<ParamArray>] args:Object [] -> unit
"""

[<Test>]
let ``should preserve brackets on type signatures``() =
formatSourceString false """
type A =
abstract member M : int -> (int -> unit)
abstract member M : float -> int""" config
|> prepend newline
|> should equal """
type A =
abstract M : int -> (int -> unit)
abstract M : float -> int
"""

[<Test>]
let ``should preserve brackets on type signatures 2``() =
formatSourceString false """
type A =
abstract member M : (int -> int) -> unit
abstract member M : float -> int""" config
|> prepend newline
|> should equal """
type A =
abstract M : (int -> int) -> unit
abstract M : float -> int
"""
6 changes: 3 additions & 3 deletions src/Fantomas.UI/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ open System.Reflection
[<assembly: AssemblyTitleAttribute("Fantomas.UI")>]
[<assembly: AssemblyProductAttribute("Fantomas")>]
[<assembly: AssemblyDescriptionAttribute("Source code formatting tool for F#")>]
[<assembly: AssemblyVersionAttribute("1.10.0")>]
[<assembly: AssemblyFileVersionAttribute("1.10.0")>]
[<assembly: AssemblyVersionAttribute("1.11.0")>]
[<assembly: AssemblyFileVersionAttribute("1.11.0")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "1.10.0"
let [<Literal>] Version = "1.11.0"
6 changes: 3 additions & 3 deletions src/Fantomas/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ open System.Runtime.CompilerServices
[<assembly: AssemblyTitleAttribute("FantomasLib")>]
[<assembly: AssemblyProductAttribute("Fantomas")>]
[<assembly: AssemblyDescriptionAttribute("Source code formatting tool for F#")>]
[<assembly: AssemblyVersionAttribute("1.10.0")>]
[<assembly: AssemblyFileVersionAttribute("1.10.0")>]
[<assembly: AssemblyVersionAttribute("1.11.0")>]
[<assembly: AssemblyFileVersionAttribute("1.11.0")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "1.10.0"
let [<Literal>] Version = "1.11.0"
16 changes: 13 additions & 3 deletions src/Fantomas/CodeFormatter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ open Fantomas.TokenMatcher
open Fantomas.FormatConfig
open Fantomas.SourceParser
open Fantomas.CodePrinter
open System.IO

let mutable internal OverridenFSharpCorePath: string option = None

Expand All @@ -29,9 +30,18 @@ let internal parseWith fileName content =
match OverridenFSharpCorePath with
| None -> checkOptions
| Some fsharpCorePath ->
{ checkOptions with OtherOptions =
[| yield "-r:" + fsharpCorePath
yield! checkOptions.OtherOptions |> Seq.filter (fun s -> not (s.Contains "FSharp.Core.dll")) |] }
let currentFSharpCoreExists =
checkOptions.OtherOptions
|> Seq.tryFind (fun s -> s.StartsWith"-r:" && s.Contains "FSharp.Core.dll")
|> Option.map (fun reference -> File.Exists reference.[3..])
|> fun arg -> defaultArg arg false
if currentFSharpCoreExists then
checkOptions
else
{ checkOptions with
OtherOptions =
[| yield "-r:" + fsharpCorePath
yield! checkOptions.OtherOptions |> Seq.filter (fun s -> not (s.Contains "FSharp.Core.dll")) |] }
// Run the first phase (untyped parsing) of the compiler
let untypedRes = checker.ParseFileInProject(fileName, content, checkOptions) |> Async.RunSynchronously
if untypedRes.ParseHadErrors then
Expand Down
5 changes: 3 additions & 2 deletions src/Fantomas/CodeFormatter.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ let test (s : string) =
fsi.AddPrinter (fun (p : pos) -> p.ToString())
fsi.AddPrinter (fun (r : range) -> r.ToString())

let input = """let inputBlah = "So, I was like, Visual Studio did wat!?"
let someBlahing = (Blah.TryCreate inputBlah).Value"""
let input = """type A =
abstract member M : (int -> int) -> int
abstract member M : float -> int"""

test input;;

Expand Down
4 changes: 2 additions & 2 deletions src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -894,10 +894,10 @@ and genTypeList astContext = function
genOnelinerAttributes astContext attribs
+> gt +> ifElse ts.IsEmpty sepNone (autoNln (sepArrow +> genTypeList astContext ts))

| (TTuple ts', ais)::ts ->
| (TTuple ts', argInfo)::ts ->
// The '/' separator shouldn't appear here
let hasBracket = not ts.IsEmpty
let gt = col sepStar (Seq.zip ais (Seq.map snd ts'))
let gt = col sepStar (Seq.zip argInfo (Seq.map snd ts'))
(fun (ArgInfo(attribs, so, isOpt), t) ->
genOnelinerAttributes astContext attribs
+> opt sepColonFixed so (if isOpt then (sprintf "?%s" >> (!-)) else (!-))
Expand Down
15 changes: 8 additions & 7 deletions src/Fantomas/SourceParser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ open System.Diagnostics
open Microsoft.FSharp.Compiler.Range
open Microsoft.FSharp.Compiler.Ast
open Microsoft.FSharp.Compiler.PrettyNaming
open Microsoft.FSharp.Compiler.Lexhelp.Keywords
open Fantomas
open Fantomas.FormatConfig
open Microsoft.FSharp.Compiler.SourceCodeServices.PrettyNaming

type Composite<'a, 'b> =
| Pair of 'b * 'b
Expand Down Expand Up @@ -1176,14 +1176,15 @@ let (|ArgInfo|) (SynArgInfo(attribs, isOpt, ido)) =
(attribs, Option.map (|Ident|) ido, isOpt)

/// Extract function arguments with their associated info
let (|FunType|) (t, ValInfo(aiss, ai)) =
let (|FunType|) (t, ValInfo(argTypes, returnType)) =
// Parse arg info by attach them into relevant types.
// The number of arg info will determine semantics of argument types.
let rec loop = function
| TFun(t1, t2), ais::aiss ->
(t1, ais)::loop(t2, aiss)
| t, [ais] -> [(t, ais)]
| t, [] -> [(t, [ai])]
| TFun(t1, t2), argType::argTypes ->
(t1, argType)::loop(t2, argTypes)
| t, [] -> [(t, [returnType])]
| _ -> []
loop(t, aiss)
loop(t, argTypes)

/// A rudimentary recognizer for extern functions
/// Probably we should use lexing information to improve its accuracy
Expand Down

0 comments on commit 100e507

Please sign in to comment.