From 21bda5bc363d9209ac202880031aebc6284237bb Mon Sep 17 00:00:00 2001 From: Florian Verdonck Date: Thu, 29 Jun 2023 14:34:53 +0200 Subject: [PATCH] Update FCS to 'Correct range of SynInterfaceImpl' (#2919) * Update FCS to 'Correct range of SynInterfaceImpl' * Remove unused files * Restore FSStrings.resx * Update test input * Add changelog entry --- CHANGELOG.md | 5 +++ Directory.Build.props | 2 +- build.fsx | 11 ------ .../AlignedMultilineBracketStyleTests.fs | 6 ++-- src/Fantomas.Core.Tests/CastTests.fs | 8 ++--- src/Fantomas.Core.Tests/CommentTests.fs | 17 ++++----- .../CrampedMultilineBracketStyleTests.fs | 18 +++++----- src/Fantomas.Core.Tests/OperatorTests.fs | 2 +- .../Stroustrup/ExperimentalElmishTests.fs | 11 +++--- .../TypeDeclarationTests.fs | 35 +++++++++++-------- src/Fantomas.Core/ASTTransformer.fs | 6 +--- src/Fantomas.FCS/Fantomas.FCS.fsproj | 31 ---------------- src/Fantomas.FCS/Parse.fs | 2 +- 13 files changed, 60 insertions(+), 94 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c63b10bd2..1aeeaee8bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 6.1.1 - 2023-06-29 + +### Changed +* Update FCS to 'Remove unused open in SyntaxTree.fs', commit 9c8b4192966e6554adc5dcc8973f2a23c8fa2722 + ## 6.1.0 - 2023-06-28 ### Fixed diff --git a/Directory.Build.props b/Directory.Build.props index d154e9e3a4..6da587b5d8 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -39,7 +39,7 @@ Some common use cases include: - 5b74995780a0e9d24a5db025e68b31e6d910f71f + 9c8b4192966e6554adc5dcc8973f2a23c8fa2722 2.8.28 6.0.1 diff --git a/build.fsx b/build.fsx index 567c44e7a0..10a2b1edaa 100644 --- a/build.fsx +++ b/build.fsx @@ -233,7 +233,6 @@ pipeline "Init" { stage "Download FCS files" { run (fun _ -> [| "src/Compiler/FSComp.txt" - "src/Compiler/Interactive/FSIstrings.txt" "src/Compiler/FSStrings.resx" "src/Compiler/Utilities/Activity.fsi" "src/Compiler/Utilities/Activity.fs" @@ -261,24 +260,16 @@ pipeline "Init" { "src/Compiler/Utilities/XmlAdapters.fs" "src/Compiler/Utilities/InternalCollections.fsi" "src/Compiler/Utilities/InternalCollections.fs" - "src/Compiler/Utilities/QueueList.fsi" - "src/Compiler/Utilities/QueueList.fs" "src/Compiler/Utilities/lib.fsi" "src/Compiler/Utilities/lib.fs" - "src/Compiler/Utilities/rational.fsi" - "src/Compiler/Utilities/rational.fs" "src/Compiler/Utilities/PathMap.fsi" "src/Compiler/Utilities/PathMap.fs" - "src/Compiler/Utilities/RidHelpers.fs" "src/Compiler/Utilities/range.fsi" "src/Compiler/Utilities/range.fs" - "src/Compiler/Facilities/UtilsStrings.txt" "src/Compiler/Facilities/LanguageFeatures.fsi" "src/Compiler/Facilities/LanguageFeatures.fs" "src/Compiler/Facilities/DiagnosticOptions.fsi" "src/Compiler/Facilities/DiagnosticOptions.fs" - "src/Compiler/Facilities/TextLayoutRender.fsi" - "src/Compiler/Facilities/TextLayoutRender.fs" "src/Compiler/Facilities/DiagnosticsLogger.fsi" "src/Compiler/Facilities/DiagnosticsLogger.fs" "src/Compiler/Facilities/prim-lexing.fsi" @@ -289,8 +280,6 @@ pipeline "Init" { "src/Compiler/AbstractIL/ilpars.fsy" "src/Compiler/AbstractIL/il.fsi" "src/Compiler/AbstractIL/il.fs" - "src/Compiler/AbstractIL/ilx.fsi" - "src/Compiler/AbstractIL/ilx.fs" "src/Compiler/AbstractIL/ilascii.fsi" "src/Compiler/AbstractIL/ilascii.fs" "src/Compiler/SyntaxTree/PrettyNaming.fsi" diff --git a/src/Fantomas.Core.Tests/AlignedMultilineBracketStyleTests.fs b/src/Fantomas.Core.Tests/AlignedMultilineBracketStyleTests.fs index b1b845901e..824d394b8e 100644 --- a/src/Fantomas.Core.Tests/AlignedMultilineBracketStyleTests.fs +++ b/src/Fantomas.Core.Tests/AlignedMultilineBracketStyleTests.fs @@ -1445,9 +1445,9 @@ let z = {| let a = {| // test1 foo with - Level = 7 - Square = 9 - // test2 + Level = 7 + Square = 9 + // test2 |} """ config diff --git a/src/Fantomas.Core.Tests/CastTests.fs b/src/Fantomas.Core.Tests/CastTests.fs index 8f53c3dd5b..f79e455494 100644 --- a/src/Fantomas.Core.Tests/CastTests.fs +++ b/src/Fantomas.Core.Tests/CastTests.fs @@ -143,9 +143,9 @@ module Foo = let foo = { new IDisposable with member __.Dispose () = - do () + do () - upcast () + upcast () } """ { config with @@ -179,9 +179,9 @@ module Foo = let foo = { new IDisposable with member __.Dispose () = - do () + do () - downcast () + downcast () } """ { config with diff --git a/src/Fantomas.Core.Tests/CommentTests.fs b/src/Fantomas.Core.Tests/CommentTests.fs index 1edd288d95..848cea159f 100644 --- a/src/Fantomas.Core.Tests/CommentTests.fs +++ b/src/Fantomas.Core.Tests/CommentTests.fs @@ -589,17 +589,18 @@ printfn "hello world" let ``preserve block comment after record, 516`` () = formatSourceString false - """module TriviaModule = + """ +module TriviaModule = -let env = "DEBUG" + let env = "DEBUG" -type Config = { - Name: string - Level: int -} + type Config = { + Name: string + Level: int + } -let meh = { // this comment right - Name = "FOO"; Level = 78 } + let meh = { // this comment right + Name = "FOO"; Level = 78 } (* ending with block comment *) """ diff --git a/src/Fantomas.Core.Tests/CrampedMultilineBracketStyleTests.fs b/src/Fantomas.Core.Tests/CrampedMultilineBracketStyleTests.fs index 0ec22f3a74..25beb3a28c 100644 --- a/src/Fantomas.Core.Tests/CrampedMultilineBracketStyleTests.fs +++ b/src/Fantomas.Core.Tests/CrampedMultilineBracketStyleTests.fs @@ -2247,9 +2247,9 @@ let z = {| let a = {| // test1 foo with - Level = 7 - Square = 9 - // test2 + Level = 7 + Square = 9 + // test2 |} """ config @@ -2355,12 +2355,12 @@ let ``multiline field body expression where indent_size = 2, update record`` () let handlerFormattedRangeDoc (lines: NamedText, formatted: string, range: FormatSelectionRange) = let range = { x with - Start = - { Line = range.StartLine - 1 - Character = range.StartColumn } - End = - { Line = range.EndLine - 1 - Character = range.EndColumn } } + Start = + { Line = range.StartLine - 1 + Character = range.StartColumn } + End = + { Line = range.EndLine - 1 + Character = range.EndColumn } } [| { Range = range; NewText = formatted } |] """ diff --git a/src/Fantomas.Core.Tests/OperatorTests.fs b/src/Fantomas.Core.Tests/OperatorTests.fs index 16af9cf6da..1f43fb8f0d 100644 --- a/src/Fantomas.Core.Tests/OperatorTests.fs +++ b/src/Fantomas.Core.Tests/OperatorTests.fs @@ -1355,7 +1355,7 @@ let ``add space around binary operators in units of measure, 2207`` () = type Test = { WorkHoursPerWeek: uint } static member create = - { WorkHoursPerWeek = 40u } + { WorkHoursPerWeek = 40u } """ { config with NewlineBetweenTypeDefinitionAndMembers = false } diff --git a/src/Fantomas.Core.Tests/Stroustrup/ExperimentalElmishTests.fs b/src/Fantomas.Core.Tests/Stroustrup/ExperimentalElmishTests.fs index 6382fb2691..3188b4fb92 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/ExperimentalElmishTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/ExperimentalElmishTests.fs @@ -163,11 +163,12 @@ let view = let ``div with multiple attributes and children`` () = formatSourceString false - """let d = -div [ ClassName "container"; OnClick (fun _ -> printfn "meh") ] [ - span [] [str "foo"] - code [] [str "bar"] -] + """ +let d = + div [ ClassName "container"; OnClick (fun _ -> printfn "meh") ] [ + span [] [str "foo"] + code [] [str "bar"] + ] """ { config with MaxArrayOrListWidth = 40 } |> prepend newline diff --git a/src/Fantomas.Core.Tests/TypeDeclarationTests.fs b/src/Fantomas.Core.Tests/TypeDeclarationTests.fs index 979052c77a..914d15faa0 100644 --- a/src/Fantomas.Core.Tests/TypeDeclarationTests.fs +++ b/src/Fantomas.Core.Tests/TypeDeclarationTests.fs @@ -1605,10 +1605,11 @@ type SomeType() = let ``split multiple parameters over multiple lines`` () = formatSourceString false - """type SomeType = + """ +type SomeType = static member SomeMember (looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1: string) (looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2: string) : string = - printfn "a" - "b" + printfn "a" + "b" """ config |> prepend newline @@ -1628,10 +1629,11 @@ type SomeType = let ``split multiple parameters over multiple lines and have correct indentation afterwards`` () = formatSourceString false - """type SomeType = + """ +type SomeType = static member SomeMember (looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1: string) (looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2: string) : string = - printfn "a" - "b" + printfn "a" + "b" static member SomeOtherMember () = printfn "c" """ @@ -1656,10 +1658,11 @@ type SomeType = let ``member with one long parameter and return type, 850`` () = formatSourceString false - """type SomeType = + """ +type SomeType = static member SomeMember loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 : string = - printfn "a" - "b" + printfn "a" + "b" """ config |> prepend newline @@ -1678,10 +1681,11 @@ type SomeType = let ``member with one long parameter and no return type, 850`` () = formatSourceString false - """type SomeType = + """ +type SomeType = static member SomeMember loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = - printfn "a" - "b" + printfn "a" + "b" """ config |> prepend newline @@ -1700,10 +1704,11 @@ type SomeType = let ``multiple members with one long parameter`` () = formatSourceString false - """type SomeType = + """ +type SomeType = static member SomeMember loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = - printfn "a" - "b" + printfn "a" + "b" static member Serialize (loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2: SomeType) = Encode.string v.Meh static member Deserialize (loooooooooooooooooooooooooooooooooooooooooooooooooooooonnnnnnnnnnnnnnnnnnnnngggggggggggJsonVaaaaalueeeeeeeeeeeeeeee) : SomeType = Decode.SomeType loooooooooooooooooooooooooooooooooooooooooooooooooooooonnnnnnnnnnnnnnnnnnnnngggggggggggJsonVaaaaalueeeeeeeeeeeeeeee diff --git a/src/Fantomas.Core/ASTTransformer.fs b/src/Fantomas.Core/ASTTransformer.fs index 551485ecf5..5898b5d795 100644 --- a/src/Fantomas.Core/ASTTransformer.fs +++ b/src/Fantomas.Core/ASTTransformer.fs @@ -1022,11 +1022,6 @@ let mkExpr (creationAide: CreationAide) (e: SynExpr) : Expr = let interfaceNodes = ims |> List.map (fun (SynInterfaceImpl(t, mWith, bs, members, StartRange 9 (mInterface, m))) -> - let m = - match List.tryLast members with - | None -> m - | Some ms -> mkRange m.FileName m.Start ms.Range.End - InterfaceImplNode( stn "interface" mInterface, mkType creationAide t, @@ -2222,6 +2217,7 @@ let mkSynLeadingKeyword (lk: SynLeadingKeyword) = | SynLeadingKeyword.Abstract abstractRange -> mtn [ "abstract", abstractRange ] | SynLeadingKeyword.AbstractMember(abstractRange, memberRange) -> mtn [ "abstract", abstractRange; "member", memberRange ] + | SynLeadingKeyword.Static staticRange -> mtn [ "static", staticRange ] | SynLeadingKeyword.StaticMember(staticRange, memberRange) -> mtn [ "static", staticRange; "member", memberRange ] | SynLeadingKeyword.StaticMemberVal(staticRange, memberRange, valRange) -> mtn [ "static", staticRange; "member", memberRange; "val", valRange ] diff --git a/src/Fantomas.FCS/Fantomas.FCS.fsproj b/src/Fantomas.FCS/Fantomas.FCS.fsproj index 3df4e6f1cc..ce91e86056 100644 --- a/src/Fantomas.FCS/Fantomas.FCS.fsproj +++ b/src/Fantomas.FCS/Fantomas.FCS.fsproj @@ -18,9 +18,6 @@ FSComp.txt - - FSIstrings.txt - FSStrings.resx FSStrings.resources @@ -103,40 +100,24 @@ Utilities\InternalCollections.fs - - Utilities\QueueList.fsi - - - Utilities\QueueList.fs - Utilities\lib.fsi Utilities\lib.fs - - Utilities\rational.fsi - - - Utilities\rational.fs - Utilities\PathMap.fsi Utilities\PathMap.fs - - Utilities\RidHelpers.fs - Utilities\range.fsi Utilities\range.fs - Facilities\LanguageFeatures.fsi @@ -149,12 +130,6 @@ Facilities\DiagnosticOptions.fs - - Facilities\TextLayoutRender.fsi - - - Facilities\TextLayoutRender.fs - Facilities\DiagnosticsLogger.fsi @@ -193,12 +168,6 @@ AbstractIL\il.fs - - AbstractIL\ilx.fsi - - - AbstractIL\ilx.fs - AbstractIL\ilascii.fsi diff --git a/src/Fantomas.FCS/Parse.fs b/src/Fantomas.FCS/Parse.fs index 8443a9e173..8e92508386 100644 --- a/src/Fantomas.FCS/Parse.fs +++ b/src/Fantomas.FCS/Parse.fs @@ -425,7 +425,7 @@ let createLexerFunction (defines: string list) lexbuf (errorLogger: CapturingDia let compilingFsLib = false let tokenizer = - LexFilter.LexFilter(lightStatus, compilingFsLib, Lexer.token lexargs true, lexbuf) + LexFilter.LexFilter(lightStatus, compilingFsLib, Lexer.token lexargs true, lexbuf, false) (fun _ -> tokenizer.GetToken())